On Thu, 17 Jul 2014 08:22:10 +0000 "Oleg Kalnichevski"
<[email protected]> wrote:
>On Wed, 2014-07-16 at 23:26 +0000, [email protected]
>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: [email protected]
>For additional commands, e-mail: httpclient-users-
>[email protected]
Here you go:
[DEBUG] 17 Jul 2014 20:09:50,086 org.apache.http.wire - http-
outgoing-0 >> "GET /?yx5bjvfxvkk89hj/Sheena.QOTJ-84).part4.rar
HTTP/1.1[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,087 org.apache.http.wire - http-
outgoing-0 >> "Host: www.mediafire.com[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,087 org.apache.http.wire - http-
outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,087 org.apache.http.wire - http-
outgoing-0 >> "User-Agent: Apache-HttpClient/4.3.4 (java
1.5)[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,087 org.apache.http.wire - http-
outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,087 org.apache.http.wire - http-
outgoing-0 >> "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "HTTP/1.1 301[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Date: Thu, 17 Jul 2014 18:09:48 GMT[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Content-Type: text/html; charset=utf-8[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Connection: close[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Cache-control: no-cache[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Expires: 0[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,317 org.apache.http.wire - http-
outgoing-0 << "Location: /download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84%29.part4.rar[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "Pragma: no-cache[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "Set-Cookie: ukey=9qpd55aze2acvfactvsjaafkfw6v90i8;
expires=Thu, 16-Jun-2016 18:09:48 GMT; path=/;
domain=.mediafire.com; httponly[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "Server: MediaFire[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "Access-Control-Allow-Origin: *[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "0[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,318 org.apache.http.wire - http-
outgoing-0 << "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,341
org.apache.http.impl.client.LaxRedirectStrategy - Redirect
requested to location '/download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84%29.part4.rar'
[DEBUG] 17 Jul 2014 20:09:50,485 org.apache.http.wire - http-
outgoing-1 >> "GET /download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84).part4.rar HTTP/1.1[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,485 org.apache.http.wire - http-
outgoing-1 >> "Host: www.mediafire.com[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,485 org.apache.http.wire - http-
outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,485 org.apache.http.wire - http-
outgoing-1 >> "User-Agent: Apache-HttpClient/4.3.4 (java
1.5)[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,485 org.apache.http.wire - http-
outgoing-1 >> "Cookie:
ukey=9qpd55aze2acvfactvsjaafkfw6v90i8[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,486 org.apache.http.wire - http-
outgoing-1 >> "Cookie2: $Version=1[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,486 org.apache.http.wire - http-
outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,486 org.apache.http.wire - http-
outgoing-1 >> "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,729 org.apache.http.wire - http-
outgoing-1 << "HTTP/1.1 301[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Date: Thu, 17 Jul 2014 18:09:48 GMT[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Content-Type: text/html; charset=utf-8[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Connection: close[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Cache-control: no-cache[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Expires: 0[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Location: /download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84%29.part4.rar[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Pragma: no-cache[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Server: MediaFire[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "Access-Control-Allow-Origin: *[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "0[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730 org.apache.http.wire - http-
outgoing-1 << "[\r][\n]"
[DEBUG] 17 Jul 2014 20:09:50,730
org.apache.http.impl.client.LaxRedirectStrategy - Redirect
requested to location '/download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84%29.part4.rar'
Exception in thread "main"
org.apache.http.client.ClientProtocolException
at
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHtt
pClient.java:186)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHtt
pClient.java:82)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHtt
pClient.java:106)
at com.wbb.lcb.core.Test2.main(Test2.java:53)
Caused by: org.apache.http.client.CircularRedirectException:
Circular redirect to
'http://www.mediafire.com/download/yx5bjvfxvkk89hj/Sheena.QOTJ-
84).part4.rar'
at
org.apache.http.impl.client.DefaultRedirectStrategy.getLocationURI(D
efaultRedirectStrategy.java:174)
at
org.apache.http.impl.client.DefaultRedirectStrategy.getRedirect(Defa
ultRedirectStrategy.java:217)
at
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.jav
a:119)
at
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHtt
pClient.java:184)
... 3 more
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]