hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From darkimmor...@hushmail.com
Subject Re: CircularRedirectException while calling URL that works in browsers
Date Fri, 18 Jul 2014 22:11:55 GMT
>As you can see the redirect location included in the response is
>relative, which is illegal. HttpClient has to normalize the 
>location URI by rewriting it as absolute. It also removes 
>escape sequences in the process, so '%29' becomes ')'.
>You can work the problem around by doing something like that
>CloseableHttpClient client = HttpClients
>        .custom()
>        .setRedirectStrategy(new DefaultRedirectStrategy() {
>            @Override
>            protected URI createLocationURI(final String location)
>throws ProtocolException {
>                return
>super.createLocationURI("http://www.mediafire.com" + location);
>            }
>        })
>        .build();
>CloseableHttpResponse response = client.execute(
>new HttpGet(
>try {
>    EntityUtils.consume(response.getEntity());
>} finally {
>    response.close();
>I would strongly suggest fixing at the server side, though.

Thank you very much for your help, Oleg. Since I am in no way 
affiliated with Medafire, I unfortunately can't fix the server. I 
did submit a support ticket requesting a fix though.

Since my client doesn't send requests just to mediafire.com, your 
workaround isn't usable in my specific case. That said, I do have 
other ideas for possible workarounds.

Thanks again,

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

View raw message