hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Oleg Kalnichevski (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-852) CircularRedirectException encountered when using a proxy, but not when reaching the target directly
Date Fri, 29 May 2009 13:02:45 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-852?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12714443#action_12714443
] 

Oleg Kalnichevski commented on HTTPCLIENT-852:
----------------------------------------------

I examined the logs and that is what I have found so far: 

The bug in HttpClient is triggered only when the redirect needs to be retried for some reason,
for instance, due to an I/O error. There appears to be a bug Tinyproxy's connection management
code causing a perfectly re-usable HTTP/1.1 connection to be dropped without proper notification
of the client. The proxy should have sent the 'Connection: close' if it was not going to re-use
HTTP/1.1connection). HttpClient assumes that the connection is still good, executes the redirect
on the same connection, which fails because the connection has been closed on the proxy side.
The second retry fails because HttpClient mistakenly assumes the URI has already been visited.

While Tinyproxy's behavior is clearly broken, HttpClient should also be able to deal with
failed redirects and retry those correctly. The fix for this issue, however, will require
quite a bit of refactoring in the DefaultRequestDirector and DefaultRedirectHandler and may
take a few days to complete. 

Oleg

> CircularRedirectException encountered when using a proxy, but not when reaching the target
directly
> ---------------------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-852
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-852
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient, HttpConn
>    Affects Versions: 4.0 Beta 2
>         Environment: Proxy: tinyproxy/1.6.4
>            Reporter: Charles Fr Rey
>             Fix For: 4.0 Beta 3
>
>         Attachments: withoutproxy.log, withproxy.log, withproxyALLOW_CIRC_RED.log
>
>
> A CircularRedirectException is encountered when using a proxy (tinyproxy on a remote
machine), whereas everything is fine when using no proxy. The target is a URL such as http://www.seoconsultants.com/w3c/status-codes/301.asp
which has a 301 redirection.
> The issue can be fixed by using ALLOW_CIRCULAR_REDIRECTS set to true (client params),
but I can't consider this a "real" fix.
> Here is a snippet of code that exemplifies the problem (use your own proxy):
> ---
> String proxyHost = "xyz.webfactional.com";
> int proxyPort = 7295;
> DefaultHttpClient httpclient = new DefaultHttpClient();
> // without a proxy it's OK!
> httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,
>         new HttpHost(proxyHost, proxyPort, "http"));
> HttpParams params = httpclient.getParams();
> HttpClientParams.setRedirecting(params, true);
> HttpProtocolParams.setUserAgent(params,
>         "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.10) Gecko/2009042315
Firefox/3.0.10");
> // OK, this fixes the problem, but at what cost / other problems ?
> //httpclient.getParams().setParameter(ClientPNames.ALLOW_CIRCULAR_REDIRECTS, true);
> String url = "http://www.seoconsultants.com/w3c/status-codes/301.asp";
> HttpUriRequest request;
> HttpResponse response;
> request = new HttpGet(url);
> System.out.println("request = " + request.getRequestLine());
> response = httpclient.execute(request);
> System.out.println("status = " + response.getStatusLine());
> System.out.println("headers = " + Arrays.asList(response.getAllHeaders()));
> ---

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message