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

Nick Trown commented on HTTPCLIENT-1641:
----------------------------------------

I've also been trying to debug the function and you are right about URI 
constructor of course.  The problem is rather subtle.  

The redirect is insisting that the parens be encoded to %28 and %29.  However, 
the parens are part of the "unreserved" character categories.  The URI 
constructor specifies that for path anything not in "unreserved", "punct", 
"escaped", or "other" categories are encoded.  Therefore "unreserved" is not 
encoded, and hence the parens are not encoded which the redirect is insisting 
on.

Using the raw path does not work and you mention as when URI constructor is 
called with the encoded characters it encodes the % that are present within.

> CircularRedirect due to rebuilding URI after decoding path, etc.
> ----------------------------------------------------------------
>
>                 Key: HTTPCLIENT-1641
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1641
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: HttpClient
>    Affects Versions: 4.3.5
>            Reporter: Nick Trown
>            Priority: Minor
>
> When I use HttpClient for the following URL the DefaultRedirectStrategy fails 
> to build a redirected URI properly.
> http://hotpads.com/apartments/Camelot-Apartments-(-Drexel-&-UPenn-)-Philadelphia-PA-19104--3phq8mahfzya3
> The reason is that the redirect URL returned is:
> /apartments/Camelot-Apartments-%28-Drexel-%26-UPenn-%29-Philadelphia-PA-19104--3phq8mahfzya3
> ** Note: the only difference is that the redirect URL has the parens encoded.
> The DefaultDirectEncoder does get the redirect URL, and since it is not 
> absolute eventually calls URIUtils.resolve().  This then calls 
> normalizeSyntax() where the bug is.
> In normalizeSyntax() the URI is reconstructed.  However, it incorrectly uses 
> getPath(), getFragment(), etc.  instead of the raw equivalents such as 
> getRawPath(), getRawFragment(), etc.
> In this case, the getPath() returned is therefore:
> apartments/Camelot-Apartments-(-Drexel-&-UPenn-)-Philadelphia-PA-19104--3phq8mahfzya3
> Where the parens are back.  The DefaultRedirectStrategy detects this as a 
> circular redirect.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to