You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Ahsan (JIRA)" <ji...@apache.org> on 2013/01/23 12:12:13 UTC
[jira] [Comment Edited] (HTTPASYNC-34) For some urls responding in
a 302 the httpget request gets stuck
[ https://issues.apache.org/jira/browse/HTTPASYNC-34?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13560556#comment-13560556 ]
Ahsan edited comment on HTTPASYNC-34 at 1/23/13 11:10 AM:
----------------------------------------------------------
Oleg,
The link gets redirected in the browser correctly. Also I tried the same url without using Async the normal httpclient it works fine.
Code used with simple HttpClient
try {
String url = "http://www.prweek.com/news/article/1167011/aeromobile-brief-moves-rooster-bell-pottinger/";
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpget = new HttpGet(url);
httpget.getParams()
.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
HttpResponse response = httpclient.execute(httpget, localContext);
HttpHost target = (HttpHost) localContext.getAttribute(
ExecutionContext.HTTP_TARGET_HOST);
HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(
ExecutionContext.HTTP_REQUEST);
System.out.println(localContext.toString());
System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
System.out.println("Target host: " + target);
System.out.println("Final request URI: " + req.getURI()); // relative URI (no proxy used)
System.out.println("Final request method: " + req.getMethod());
} catch (Exception ex) {
ex.printStackTrace();
}
was (Author: nasha):
Oleg,
The link gets redirected in the browser correctly. Also I tried the same url with using Async the normal httpclient it works fine.
Code used with simple HttpClient
try {
String url = "http://www.prweek.com/news/article/1167011/aeromobile-brief-moves-rooster-bell-pottinger/";
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpget = new HttpGet(url);
httpget.getParams()
.setParameter(ClientPNames.COOKIE_POLICY, CookiePolicy.RFC_2965);
HttpResponse response = httpclient.execute(httpget, localContext);
HttpHost target = (HttpHost) localContext.getAttribute(
ExecutionContext.HTTP_TARGET_HOST);
HttpUriRequest req = (HttpUriRequest) localContext.getAttribute(
ExecutionContext.HTTP_REQUEST);
System.out.println(localContext.toString());
System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
System.out.println("Target host: " + target);
System.out.println("Final request URI: " + req.getURI()); // relative URI (no proxy used)
System.out.println("Final request method: " + req.getMethod());
} catch (Exception ex) {
ex.printStackTrace();
}
> For some urls responding in a 302 the httpget request gets stuck
> ----------------------------------------------------------------
>
> Key: HTTPASYNC-34
> URL: https://issues.apache.org/jira/browse/HTTPASYNC-34
> Project: HttpComponents HttpAsyncClient
> Issue Type: Bug
> Affects Versions: 4.0-beta3
> Environment: Debian 6, Java 1.6
> Reporter: Ahsan
> Priority: Blocker
> Fix For: 4.0-beta4
>
>
> 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");
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org