You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by da...@hushmail.com on 2014/07/17 01:26:43 UTC

CircularRedirectException while calling URL that works in browsers

Hello,

I'm currently trying to call an URL that works fine in IE, Firefox 
and Chrome but gives me a CircularRedirectException with HttpClient.

First of all, here is a small test case:

    public static void main(String[] args) throws 
ClientProtocolException, IOException {

            HttpClientBuilder clientBuilder = HttpClients.custom();
            clientBuilder.setRedirectStrategy(new 
LaxRedirectStrategy());
        
            CloseableHttpClient httpclient = clientBuilder.build();

            String url = 
"http://www.mediafire.com/?yx5bjvfxvkk89hj/Sheena.QOTJ-
84).part4.rar";

            HttpRequestBase request = new HttpGet(url);

            httpclient.execute(request);
    }


After checking with Wireshark, this is apparently what happens:

1. "/?yx5bjvfxvkk89hj/Sheena.QOTJ-84).part4.rar" gets called.
2. We get a 301 response with the location 
"/download/yx5bjvfxvkk89hj/Sheena.QOTJ-84%29.part4.rar"
3. "/download/yx5bjvfxvkk89hj/Sheena.QOTJ-84).part4.rar" gets 
called.
4. We get the same 301 response again.

Notice that in step 3 there is a ) in the URL while the response 
specifies %29 instead. Browsers do not make this conversion and get 
the correct web page instead.

Could you kindly tell me if I'm doing anything wrong?

Regards,
DSA


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


Re: CircularRedirectException while calling URL that works in browsers

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2014-07-16 at 23:26 +0000, darkimmortal@hushmail.com wrote:
> Hello,
> 
> I'm currently trying to call an URL that works fine in IE, Firefox 
> and Chrome but gives me a CircularRedirectException with HttpClient.
> 
> First of all, here is a small test case:
> 
>     public static void main(String[] args) throws 
> ClientProtocolException, IOException {
> 
>             HttpClientBuilder clientBuilder = HttpClients.custom();
>             clientBuilder.setRedirectStrategy(new 
> LaxRedirectStrategy());
>         
>             CloseableHttpClient httpclient = clientBuilder.build();
> 
>             String url = 
> "http://www.mediafire.com/?yx5bjvfxvkk89hj/Sheena.QOTJ-
> 84).part4.rar";
> 
>             HttpRequestBase request = new HttpGet(url);
> 
>             httpclient.execute(request);
>     }
> 
> 
> After checking with Wireshark, this is apparently what happens:
> 
> 1. "/?yx5bjvfxvkk89hj/Sheena.QOTJ-84).part4.rar" gets called.
> 2. We get a 301 response with the location 
> "/download/yx5bjvfxvkk89hj/Sheena.QOTJ-84%29.part4.rar"
> 3. "/download/yx5bjvfxvkk89hj/Sheena.QOTJ-84).part4.rar" gets 
> called.
> 4. We get the same 301 response again.
> 
> Notice that in step 3 there is a ) in the URL while the response 
> specifies %29 instead. Browsers do not make this conversion and get 
> the correct web page instead.
> 
> Could you kindly tell me if I'm doing anything wrong?
> 
> Regards,
> DSA
> 
> 

Please post a complete wire / context log of the session

http://hc.apache.org/httpcomponents-client-4.3.x/logging.html

Oleg



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