On 16/09/2008, Oleg Kalnichevski <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-09-16 at 12:45 -0700, Subashini S wrote:
>  > Hi,
>  >
>  > I've come across a scenario where the location:
>  > http://www.nwsource.com/travel/scr/tf_destination.cfm? When requested in 
> IE browser comes back with the following response code:
>  > GET http://www.nwsource.com/travel/scr/tf_destination.cfm? 302 Moved 
> Temporarily to ''
>  > When the successive requests were studied, IE browser seems to make 
> requests as follows:
>  >
>  > GET    http://www.nwsource.com/travel/scr/tf_destination.cfm?    302 Moved 
> Temporarily to ''
>  > GET    http://www.nwsource.com/travel/scr/                       302 Moved 
> Temporarily to /travel/
>  > GET    http://www.nwsource.com/travel/                           301 Moved 
> Permanently to http://www.nwsource.com/travel
>  > So finally the browser renders the page: http://www.nwsource.com/travel. 
> However with httpclient, when the first request is made, the response  header 
> comes back with blank value for location.
>  > GET    http://www.nwsource.com/travel/scr/tf_destination.cfm?    302 Moved 
> Temporarily to ''
>  > Whenever there is a redirection to a relative url, the url is absolutized 
> and fetched. In our case however, the redirected url happens to be a blank 
> string and hence when absolutizing, the original url is returned. And hence, 
> goes into infinite redirection.
>  >
>  > if (redirectUri.isRelativeURI()) {
>  >     if 
> (this.params.isParameterTrue(HttpClientParams.REJECT_RELATIVE_REDIRECT)) {
>  >         LOG.warn("Relative redirect location '" + location + "' not 
> allowed");
>  >         return false;
>  >     } else {
>  >         //location is incomplete, use current values for defaults
>  >         LOG.debug("Redirect URI is not absolute - parsing as relative");
>  >         redirectUri = new URI(currentUri, redirectUri);
>  >     }
>  >
>  >
>  > The control comes to the else part of this snippet in 
> org.apache.commons.httpclient.HttpMethodDirector class
>  > and we are getting the following output:
>  > Narrowly avoided an infinite loop in execute
>  > caught org.apache.commons.httpclient.RedirectException: Maximum redirects 
> (100) exceeded
>  >
>  > Has anyone come across a similar situation where the redirect location is 
> blank. If so is it possible to emulate browser behaviour without a code 
> change in httpclient?
>  >
>
>
> Subashini,
>
>  If upgrading to HttpClient 4.0 is an option, you could plug in a custom
>  RedirectHandler impl in order to emulate IE compatible behavior

Note that neither Firefox nor Opera (nor Java http) handle the URL
correctly, so if any such URLs are expected to be used much, perhaps
the website owners should be informed...

>  
> http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/RedirectHandler.html
>
>  With HttpClient 3.x you do not have that many options. The only
>  possibility would be disabling automatic redirects and handling all
>  redirects manually.
>
>
>  Oleg
>
>
>  > Thanks in advance,
>  > Subashini
>  >
>  >
>  >
>  >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: [EMAIL PROTECTED]
>  > For additional commands, e-mail: [EMAIL PROTECTED]
>  >
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to