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

Oleg Kalnichevski commented on HTTPCLIENT-1452:
-----------------------------------------------

In my tests HttpClient handle the url just fine. Do you by any chance set 
'Host' header manually in your request?

{noformat}
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: 
{}->http://it.bing.com:80][total kept alive: 0; route allocated: 0 of 2; total 
allocated: 0 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: 
{}->http://it.bing.com:80][total kept alive: 0; route allocated: 1 of 2; total 
allocated: 1 of 20]
[DEBUG] MainClientExec - Opening connection {}->http://it.bing.com:80
[DEBUG] HttpClientConnectionManager - Connecting to 
it.bing.com/204.79.197.200:80
[DEBUG] MainClientExec - Executing request GET / HTTP/1.1
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-0 >> GET / HTTP/1.1
[DEBUG] headers - http-outgoing-0 >> Host: it.bing.com
[DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.3.1 (java 
1.5)
[DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[DEBUG] headers - http-outgoing-0 << HTTP/1.1 302 Found
[DEBUG] headers - http-outgoing-0 << Content-Length: 0
[DEBUG] headers - http-outgoing-0 << Cache-Control: private
[DEBUG] headers - http-outgoing-0 << Date: Mon, 27 Jan 2014 09:12:13 GMT
[DEBUG] headers - http-outgoing-0 << Edge-control: no-store
[DEBUG] headers - http-outgoing-0 << Location: http://www.bing.com/
[DEBUG] headers - http-outgoing-0 << P3P: CP="NON UNI COM NAV STA LOC CURa DEVa 
PSAa PSDa OUR IND"
[DEBUG] headers - http-outgoing-0 << Server: Microsoft-IIS/8.0
[DEBUG] headers - http-outgoing-0 << Set-Cookie: _HOP=I=1&TS=1390813933; 
domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-0 << X-MSEdge-Ref: Ref A: 
1D47A4EC6C8D4FD4A6ABA6C7F18A77A2 Ref B: E4AE72DBE1A868881FAE39430226A82D Ref C: 
Mon Jan 27 01:12:13 2014 PST
[DEBUG] MainClientExec - Connection can be kept alive indefinitely
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
_HOP][value: I=1&TS=1390813933][domain: .bing.com][path: /][expiry: null]". 
[DEBUG] DefaultRedirectStrategy - Redirect requested to location 
'http://www.bing.com/'
[DEBUG] RedirectExec - Resetting target auth state
[DEBUG] RedirectExec - Redirecting to 'http://www.bing.com/' via 
{}->http://www.bing.com:80
[DEBUG] PoolingHttpClientConnectionManager - Connection [id: 0][route: 
{}->http://it.bing.com:80] can be kept alive indefinitely
[DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 
0][route: {}->http://it.bing.com:80][total kept alive: 1; route allocated: 1 of 
2; total allocated: 1 of 20]
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: _HOP][value: 
I=1&TS=1390813933][domain: .bing.com][path: /][expiry: null] match 
[www.bing.com:80/]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: 
{}->http://www.bing.com:80][total kept alive: 1; route allocated: 0 of 2; total 
allocated: 1 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 1][route: 
{}->http://www.bing.com:80][total kept alive: 1; route allocated: 1 of 2; total 
allocated: 2 of 20]
[DEBUG] MainClientExec - Opening connection {}->http://www.bing.com:80
[DEBUG] HttpClientConnectionManager - Connecting to 
www.bing.com/204.79.197.200:80
[DEBUG] MainClientExec - Executing request GET / HTTP/1.1
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-1 >> GET / HTTP/1.1
[DEBUG] headers - http-outgoing-1 >> Host: www.bing.com
[DEBUG] headers - http-outgoing-1 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-1 >> User-Agent: Apache-HttpClient/4.3.1 (java 
1.5)
[DEBUG] headers - http-outgoing-1 >> Cookie: _HOP=I=1&TS=1390813933
[DEBUG] headers - http-outgoing-1 >> Cookie2: $Version=1
[DEBUG] headers - http-outgoing-1 >> Accept-Encoding: gzip,deflate
[DEBUG] headers - http-outgoing-1 << HTTP/1.1 200 OK
[DEBUG] headers - http-outgoing-1 << Content-Type: text/html; charset=utf-8
[DEBUG] headers - http-outgoing-1 << Transfer-Encoding: chunked
[DEBUG] headers - http-outgoing-1 << Cache-Control: private, max-age=0
[DEBUG] headers - http-outgoing-1 << Date: Mon, 27 Jan 2014 09:12:13 GMT
[DEBUG] headers - http-outgoing-1 << Edge-control: no-store
[DEBUG] headers - http-outgoing-1 << P3P: CP="NON UNI COM NAV STA LOC CURa DEVa 
PSAa PSDa OUR IND"
[DEBUG] headers - http-outgoing-1 << Server: Microsoft-IIS/8.0
[DEBUG] headers - http-outgoing-1 << Set-Cookie: _FP=EM=1; expires=Wed, 
27-Jan-2016 09:12:13 GMT; domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: _FS=NU=1; domain=.bing.com; 
path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: _HOP=; domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
_SS=SID=DC4C8923094E4A03B1F755E1AE7A516D; domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
MUID=0894F6C9C2B063850387F306C391634C; expires=Wed, 27-Jan-2016 09:12:13 GMT; 
domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
MUIDB=0894F6C9C2B063850387F306C391634C; expires=Wed, 27-Jan-2016 09:12:13 GMT; 
path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
OrigMUID=0894F6C9C2B063850387F306C391634C%2c7f34e0f623a34b9e909e7f6dd3ae428f; 
expires=Wed, 27-Jan-2016 09:12:13 GMT; domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
SRCHD=D=3194472&MS=3194472&AF=NOFORM; expires=Wed, 27-Jan-2016 09:12:13 GMT; 
domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
SRCHUID=V=2&GUID=610E5FF2D3E54349820C0345EAF8DD77; expires=Wed, 27-Jan-2016 
09:12:13 GMT; path=/
[DEBUG] headers - http-outgoing-1 << Set-Cookie: 
SRCHUSR=AUTOREDIR=0&GEOVAR=&DOB=20140127; expires=Wed, 27-Jan-2016 09:12:13 
GMT; domain=.bing.com; path=/
[DEBUG] headers - http-outgoing-1 << X-MSEdge-Ref: Ref A: 
8F64B72A6FB245FEA437BCFC4289B0E0 Ref B: BF878FE1A8A69C061851F1ABAC706BAE Ref C: 
Mon Jan 27 01:12:13 2014 PST
[DEBUG] MainClientExec - Connection can be kept alive indefinitely
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
_FP][value: EM=1][domain: .bing.com][path: /][expiry: Wed Jan 27 10:12:13 CET 
2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
_FS][value: NU=1][domain: .bing.com][path: /][expiry: null]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
_HOP][value: ][domain: .bing.com][path: /][expiry: null]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
_SS][value: SID=DC4C8923094E4A03B1F755E1AE7A516D][domain: .bing.com][path: 
/][expiry: null]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
MUID][value: 0894F6C9C2B063850387F306C391634C][domain: .bing.com][path: 
/][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
MUIDB][value: 0894F6C9C2B063850387F306C391634C][domain: www.bing.com][path: 
/][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
OrigMUID][value: 
0894F6C9C2B063850387F306C391634C%2c7f34e0f623a34b9e909e7f6dd3ae428f][domain: 
.bing.com][path: /][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
SRCHD][value: D=3194472&MS=3194472&AF=NOFORM][domain: .bing.com][path: 
/][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
SRCHUID][value: V=2&GUID=610E5FF2D3E54349820C0345EAF8DD77][domain: 
www.bing.com][path: /][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: 
SRCHUSR][value: AUTOREDIR=0&GEOVAR=&DOB=20140127][domain: .bing.com][path: 
/][expiry: Wed Jan 27 10:12:13 CET 2016]". 
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-1: Shutdown 
connection
[DEBUG] MainClientExec - Connection discarded
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-1: Close connection
[DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 
1][route: {}->http://www.bing.com:80][total kept alive: 1; route allocated: 0 
of 2; total allocated: 1 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection manager is shutting down
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
[DEBUG] PoolingHttpClientConnectionManager - Connection manager shut down
{noformat}

{code:java}
HttpClientContext context = HttpClientContext.create();
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
    CloseableHttpResponse response = httpclient.execute(new 
HttpGet("http://it.bing.com";), context);
    try {
        // ...
    } finally {
        response.close();
    }
} finally {
    httpclient.close();
}

{code}

> in case of a redirect a wrong host param is set to http header
> --------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1452
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1452
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.1
>            Reporter: Lars Bachmann
>         Attachments: wire.log
>
>
> The following url will lead to a circular redirect and a 
> CircularRedirectException in the end:
> http://it.bing.com/
> The reason is that http://it.bing.com will redirect to http://www.bing.com 
> but the header param "host" is not set to the new host (bing.com), instead 
> the host param of the original request (it.bing.com) is used. In the end the 
> redirect request will not call http://www.bing.com but http://it.bing.com 
> instead, which is the same location like the original url and will end up in 
> a circular deadlock.
> The fix would be to override the host param with the value of the redirect 
> request after copying all header params from the original request to the 
> redirect request.
> The class to adjust is: 
> org.apache.http.impl.client.DefaultRequestDirector.java
> The problem is also addressed here:
> http://stackoverflow.com/questions/6698214/avoid-circular-redirect-using-httpclient-4-1-1



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to