hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Fansky (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-899) Traling slash is not added to the end of Location header value when proccessing redirect.
Date Fri, 11 Dec 2009 12:43:18 GMT

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

Alexey Fansky commented on HTTPCLIENT-899:
------------------------------------------

I have found temporary solution for this issue, but is needs testing.

Index: D:/SEO/Coding/hc/org/apache/http/impl/client/DefaultRedirectHandler.java
===================================================================
--- D:/SEO/Coding/hc/org/apache/http/impl/client/DefaultRedirectHandler.java	Fri Dec 11 14:01:05
EET 2009
+++ D:/SEO/Coding/hc/org/apache/http/impl/client/DefaultRedirectHandler.java	Fri Dec 11 14:01:05
EET 2009
@@ -105,7 +105,14 @@
                     + " but no location header");
         }
         String location = locationHeader.getValue();
+
+        if(!location.contains("?") && !location.endsWith("/")) {
-        if (this.log.isDebugEnabled()) {
+            if (this.log.isDebugEnabled()) {
+                this.log.debug("Adding trailing slash to location: '" + location + "'");
+            }
+            location = location + "/";
+        }
+        if (this.log.isDebugEnabled()) {
             this.log.debug("Redirect requested to location '" + location + "'");
         }
 


> Traling slash is not added to the end of Location header value when proccessing redirect.
> -----------------------------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-899
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-899
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 4.0.1
>         Environment: httpclient-4.0.1
>            Reporter: Alexey Fansky
>
> When httpclient receives 302(or any other redirect) response from server, it redirects
directly to Location header value without adding trailing slash to the end of uri. Please
see log:
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultClientConnection
- Receiving response: HTTP/1.0 302 Found
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << HTTP/1.0 302
Found
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Date: Fri,
11 Dec 2009 11:01:05 GMT
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Server: ZX_Spectrum/1997
(Sinclair_BASIC)
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Set-Cookie:
Virtual_id=26; path=/; domain=.yandex.ru;
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Location:
http://narod.yandex.ru
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Content-Type:
text/html; charset=windows-1251
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << X-Cache: MISS
from narod.yandex.ru
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.headers - << Connection:
close
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.ResponseProcessCookies
- Cookie accepted: "[version: 0][name: Virtual_id][value: 26][domain: .yandex.ru][path: /][expiry:
null]". 
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.DefaultRedirectHandler
- Redirect requested to location 'http://narod.yandex.ru'
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.route.default-proxy': http://79.117.160.xxx:8000
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.DefaultRequestDirector
- Redirecting to 'http://narod.yandex.ru' via HttpRoute[{}->http://79.117.160.xxx:8000->http://narod.yandex.ru]
> 13:01:03,627 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultClientConnection
- Connection closed
> 13:01:03,811 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.tcp.nodelay': true
> 13:01:03,811 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.socket.buffer-size': 8192
> 13:01:03,811 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.protocol.version': HTTP/1.1
> 13:01:03,811 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.useragent': Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en) Opera 8.02
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.ClientParamsStack
- 'http.protocol.cookie-policy': compatibility
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- CookieSpec selected: compatibility
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: yandex_mail][value: o-razocharovannyi2009][domain: .yandex.ru][path:
/][expiry: null] match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: yandex_login][value: o.razocharovannyi2009][domain: .yandex.ru][path:
/][expiry: null] match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: Session_id][value: 1260529235.-4301.0.79308534.2:216563882:250.8:1260529235871:1333108959:15.62953.10893.2cc1963276a9d131887679b99a753abf][domain:
.yandex.ru][path: /][expiry: null] match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: L][value: Rlc7XlBoBGJjY0FWfkZ4WnVWAlhja1puCQ1FKUVAVjUBXTMMHwQuCQwXZxgXDSgiXS9KXj4QWhouDGAJSFY1fw==.1260529235.6343.211563.a4588e45abb86ea112f2c24ab959eca9][domain:
.yandex.ru][path: /][expiry: Thu Mar 11 13:00:35 EET 2010] match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: yandexuid][value: 872959911260529238][domain: .yandex.ru][path:
/][expiry: Mon Dec 09 13:00:38 EET 2019] match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.client.protocol.RequestAddCookies
- Cookie [version: 0][name: Virtual_id][value: 26][domain: .yandex.ru][path: /][expiry: null]
match [narod.yandex.ru:80/]
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.impl.client.DefaultRequestDirector
- Attempt 5 to execute request
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultClientConnection
- Sending request: GET http://narod.yandex.ru HTTP/1.1
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "GET http://narod.yandex.ru
HTTP/1.1[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "Host: narod.yandex.ru[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "Proxy-Connection:
Keep-Alive[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "User-Agent:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en) Opera 8.02[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "Cookie: yandex_mail=o-razocharovannyi2009;
yandex_login=o.razocharovannyi2009; Session_id=1260529235.-4301.0.79308534.2:216563882:250.8:1260529235871:1333108959:15.62953.10893.2cc1963276a9d131887679b99a753abf;
L=Rlc7XlBoBGJjY0FWfkZ4WnVWAlhja1puCQ1FKUVAVjUBXTMMHwQuCQwXZxgXDSgiXS9KXj4QWhouDGAJSFY1fw==.1260529235.6343.211563.a4588e45abb86ea112f2c24ab959eca9;
yandexuid=872959911260529238; Virtual_id=26[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.wire - >> "[EOL]"
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.headers - >> GET http://narod.yandex.ru
HTTP/1.1
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.headers - >> Host: narod.yandex.ru
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.headers - >> Proxy-Connection:
Keep-Alive
> 13:01:03,812 DEBUG threadPoolExecuter-1 org.apache.http.headers - >> User-Agent:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; en) Opera 8.02
> 13:01:03,813 DEBUG threadPoolExecuter-1 org.apache.http.headers - >> Cookie: yandex_mail=o-razocharovannyi2009;
yandex_login=o.razocharovannyi2009; Session_id=1260529235.-4301.0.79308534.2:216563882:250.8:1260529235871:1333108959:15.62953.10893.2cc1963276a9d131887679b99a753abf;
L=Rlc7XlBoBGJjY0FWfkZ4WnVWAlhja1puCQ1FKUVAVjUBXTMMHwQuCQwXZxgXDSgiXS9KXj4QWhouDGAJSFY1fw==.1260529235.6343.211563.a4588e45abb86ea112f2c24ab959eca9;
yandexuid=872959911260529238; Virtual_id=26
> 13:01:06,374 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "<!DOCTYPE
HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">[EOL]"
> 13:01:06,374 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
> 13:01:06,374 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "<HTML><HEAD>[EOL]"
> 13:01:06,374 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: <HTML><HEAD>
> 13:01:06,374 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "<TITLE>400
Bad Request</TITLE>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: <TITLE>400 Bad Request</TITLE>
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "</HEAD><BODY>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: </HEAD><BODY>
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "<H1>Bad
Request</H1>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: <H1>Bad Request</H1>
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "Your browser
sent a request that this server could not understand.<P>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: Your browser sent a request that this server could not understand.<P>
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "Invalid URI
in request GET  HTTP/1.1<P>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: Invalid URI in request GET  HTTP/1.1<P>
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.wire - << "</BODY></HTML>[EOL]"
> 13:01:06,375 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultResponseParser
- Garbage in response: </BODY></HTML>
> 13:01:08,374 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultClientConnection
- Connection closed
> 13:01:08,374 DEBUG threadPoolExecuter-1 org.apache.http.impl.conn.DefaultClientConnection
- Connection shut down

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message