@@ -0,0 +1,3352 @@
+package com.ning.http.client.async;%0A%0Aimport com.ning.http.client.AsyncCompletionHandlerBase;%0Aimport com.ning.http.client.AsyncHttpClient;%0Aimport com.ning.http.client.Request;%0Aimport com.ning.http.client.RequestBuilder;%0Aimport com.ning.http.client.RequestType;%0Aimport com.ning.http.client.Response;%0Aimport org.apache.log4j.BasicConfigurator;%0Aimport org.mortbay.jetty.Connector;%0Aimport org.mortbay.jetty.Server;%0Aimport org.mortbay.jetty.handler.AbstractHandler;%0Aimport org.mortbay.jetty.nio.SelectChannelConnector;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0A%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.io.IOException;%0Aimport java.util.concurrent.BrokenBarrierException;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.ExecutionException;%0Aimport java.util.concurrent.TimeUnit;%0Aimport java.util.concurrent.TimeoutException;%0A%0A/**%0A * Tests HEAD request that gets 302 response.%0A *%0A * @author Hubert Iwaniuk%0A */%0Apublic class Head302Test extends AbstractBasicTest %7B%0A    /**%0A     * Handler that does Moved (302) in response to HEAD method.%0A     */%0A    private class Head302handler extends AbstractHandler %7B%0A        public void handle(String s,%0A                           HttpServletRequest request,%0A                           HttpServletResponse response,%0A                           int i) throws IOException, ServletException %7B%0A            if (%22HEAD%22.equalsIgnoreCase(request.getMethod())) %7B%0A                if (request.getPathInfo().endsWith(%22_moved%22)) %7B%0A                    response.setStatus(HttpServletResponse.SC_OK);%0A                %7D else %7B%0A                    response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); // 302%0A                    response.setHeader(%22Location%22, request.getPathInfo() + %22_moved%22);%0A                %7D%0A            %7D else %7B // this handler is to handle HEAD reqeust%0A                response.setStatus(HttpServletResponse.SC_FORBIDDEN);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Test(enabled = false)%0A    public void testHEAD302() throws IOException, BrokenBarrierException, InterruptedException, ExecutionException, TimeoutException %7B%0A        AsyncHttpClient client = new AsyncHttpClient();%0A        final CountDownLatch l = new CountDownLatch(1);%0A        Request request = new RequestBuilder(RequestType.HEAD).setUrl(%22http://localhost:%22 + PORT + %22/Test%22).build();%0A%0A        client.executeRequest(request, new AsyncCompletionHandlerBase() %7B%0A            @Override%0A            public Response onCompleted(Response response) throws Exception %7B%0A                l.countDown();%0A                return super.onCompleted(response);%0A            %7D%0A        %7D).get(3, TimeUnit.SECONDS);%0A%0A        if (!l.await(5, TimeUnit.SECONDS)) %7B%0A            Assert.fail(%22Timeout out%22);%0A        %7D%0A    %7D%0A%0A    @BeforeClass(alwaysRun = true)%0A    public void setUpGlobal() throws Exception %7B%0A        server = new Server();%0A        BasicConfigurator.configure();%0A%0A        Connector listener = new SelectChannelConnector();%0A%0A        listener.setHost(%22127.0.0.1%22);%0A        listener.setPort(PORT);%0A        server.addConnector(listener);%0A%0A        server.setHandler(new Head302handler());%0A        server.start();%0A        log.info(%22Local HTTP server started successfully%22);%0A    %7D%0A%7D

Add a new test from Hubert, but do not enable it until Netty issue https://jira.jboss.org/jira/browse/NETTY-302 is fixed