[ https://issues.apache.org/jira/browse/HTTPCLIENT-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16760274#comment-16760274 ]
Jay Modi commented on HTTPCLIENT-1968: -------------------------------------- {quote}State a specific use case with a unit test {quote} The patch that I've attached has a unit test for ensuring that rewriteUri does not lose encoded slashes. Ideally is should be that any reserved character that is encoded within a URI should not be lost during a rewrite. {quote}It might be possible to workaround this with documentation. Is it? {quote} Currently there is a workaround, but it involves an application specifically crafting the URI the right way so that it doesn't go through the rewriteUri method that does normalization. I personally feel like documenting that is leaking too much of the internal workings/implementation details to the client. {quote}work around the fact that {{java.net.URI}} represents the path element as a single decoded string rather than an array of path segments. {quote} I think path normalization and preservation of reserved characters is still possible using by using java.net.URI#getRawPath, which preserves the original encoding. The path can then be split based on non encoded forward slashes and normalized. The path can then be reconstructed with the escaped reserved characters being encoded. I'm happy to work on this with tests and all if this is acceptable. Ultimately taking an array of path parts would probably be an ideal enhancement for UriBuilder. > Encoded forward slashes are not preserved when rewriting URI > ------------------------------------------------------------ > > Key: HTTPCLIENT-1968 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1968 > Project: HttpComponents HttpClient > Issue Type: Bug > Affects Versions: 4.5.7 > Reporter: Jay Modi > Priority: Major > Attachments: rewrite_preserve_forward_slash.diff > > > URIs that contain an encoded forward slash (%2F) are no longer preserved when > the HTTP client executes. I came across this when upgrading from 4.5.2 to > 4.5.7 and my requests that contained an encoded forward slash suddenly > started failing. The appears to be due to decoding and re-encoding of the > path that takes place in the URIUtils#rewriteURI method. I've attached a > patch that restores the old behavior but if a URI contains two slashes in a > row in addition to an encoded slash the encoded forward slash will be decoded. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org