[ https://issues.apache.org/jira/browse/HTTPCLIENT-1968?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16771439#comment-16771439 ]
Matt Nelson commented on HTTPCLIENT-1968: ----------------------------------------- {quote} The conversation here is only about slashes. However any encoding breaks (in our case encoded colons). {quote} Adding another use case where encoded commas in the path are treated differently based on the build flow. Construction vs fluent builder. {code} @Test public void uribuilder() throws URISyntaxException { final String rawURI = "http://localhost/service/before1%2Cafter1,before2%2Cafter2?qp1=1&qp2=2"; System.out.println("raw uri"); System.out.println(rawURI); final URI uri = new URIBuilder(rawURI).build(); System.out.println("builder from URI"); System.out.println(uri); final URI fluentURI = new URIBuilder() .setHost(uri.getHost()) .setPath(uri.getPath()) .setCustomQuery(uri.getQuery()) .setScheme(uri.getScheme()) .build(); System.out.println("fluent builder using setQuery"); System.out.println(fluentURI); final URIBuilder urib = new URIBuilder() .setHost(uri.getHost()) .setPath(uri.getPath()) .setCustomQuery(uri.getQuery()) .setScheme(uri.getScheme()); Arrays.asList(uri.getQuery().split("&")).stream() .forEach( q -> { final String[] value = q.split("="); urib.setParameter(value[0], value[1]); }); System.out.println("fluent builder using setParameter"); System.out.println(urib.build()); } {code} {noformat} raw uri http://localhost/service/before1%2Cafter1,before2%2Cafter2?qp1=1&qp2=2 builder from URI http://localhost/service/before1%2Cafter1,before2%2Cafter2?qp1=1&qp2=2 fluent builder using setQuery http://localhost/service/before1,after1,before2,after2?qp1=1&qp2=2 fluent builder using setParameter http://localhost/service/before1,after1,before2,after2?qp1=1&qp2=2 {noformat} > 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 > > Time Spent: 3.5h > Remaining Estimate: 0h > > 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