Uploaded image for project: 'HttpComponents HttpAsyncClient'
  1. HttpComponents HttpAsyncClient
  2. HTTPASYNC-34

For some urls responding in a 302 the httpget request gets stuck

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • 4.0-beta3
    • 4.0-beta4
    • None
    • Debian 6, Java 1.6

    Description

      For some urls responding in a 302 the httpget request gets stuck. e.g http://www.prweek.com/news/article/1167011/aeromobile-brief-moves-rooster-bell-pottinger/

      Here is the code:
      import java.util.concurrent.CountDownLatch;

      import org.apache.http.HttpResponse;
      import org.apache.http.client.methods.HttpGet;
      import org.apache.http.concurrent.FutureCallback;
      import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
      import org.apache.http.nio.client.HttpAsyncClient;
      import org.apache.http.params.CoreConnectionPNames;

      public class AsyncClientHttpExchangeFutureCallback {

      public static void main(String[] args) throws Exception {
      HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
      httpclient.getParams()
      .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 3000)
      .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000)
      .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
      .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true);

      httpclient.start();
      try {
      HttpGet[] requests = new HttpGet[]

      { new HttpGet("http://www.prweek.com/news/article/1167011/aeromobile-brief-moves-rooster-bell-pottinger/") }

      ;
      final CountDownLatch latch = new CountDownLatch(requests.length);
      for (final HttpGet request: requests) {
      httpclient.execute(request, new FutureCallback<HttpResponse>() {

      public void completed(final HttpResponse response)

      { latch.countDown(); System.out.println(request.getRequestLine() + "->" + response.getStatusLine()); }

      public void failed(final Exception ex)

      { latch.countDown(); System.out.println(request.getRequestLine() + "->" + ex); }

      public void cancelled()

      { latch.countDown(); System.out.println(request.getRequestLine() + " cancelled"); }

      });
      }
      latch.await();
      System.out.println("Shutting down");
      } finally

      { httpclient.shutdown(); }

      System.out.println("Done");
      }

      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nasha Ahsan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: