You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/08/05 09:23:00 UTC
[jira] [Commented] (HTTPCORE-628) URIBuilder:: query parameters are
encoded differently compared to java.lang.URI
[ https://issues.apache.org/jira/browse/HTTPCORE-628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17171369#comment-17171369 ]
ASF subversion and git services commented on HTTPCORE-628:
----------------------------------------------------------
Commit 01384e335d7ee17d7ce016b7d5e4c8c13f56756f in httpcomponents-core's branch refs/heads/5.1.x from Oleg Kalnichevski
[ https://gitbox.apache.org/repos/asf?p=httpcomponents-core.git;h=01384e3 ]
HTTPCORE-628: do not encode blanks as + in URI query component
> URIBuilder:: query parameters are encoded differently compared to java.lang.URI
> -------------------------------------------------------------------------------
>
> Key: HTTPCORE-628
> URL: https://issues.apache.org/jira/browse/HTTPCORE-628
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Components: HttpCore
> Affects Versions: 5.0
> Environment: Java EE; Vaadin; Glassfish 5
> Reporter: Torsten Rendelmann
> Priority: Minor
> Fix For: 5.1
>
>
> If we build an URI using java.lang.URI, the encoding of the query parameters are different compared to build the URI using URIBuilder. The URIBuilder uses e.g. "+" to encode spaces (by default) while java.lang.URI uses (the expected) "%20" hex encoding for spaces.
> Test that show the problem:
> {code:java}
> @Test
> public void testAddParameterEncodingEquivalence() throws Exception {
> final URI uri = new URI("http", null, "localhost", 80, "/",
> "param=stuff with spaces", null);
> final URIBuilder uribuilder = new URIBuilder().setScheme("http").setHost("localhost").setPort(80).setPath("/").addParameter(
> "param", "stuff with spaces");
> final URI result = uribuilder.build();
> Assert.assertEquals(uri, result);
> }
> {code}
> Think, there is a platform mismatch the URIBuilder is thought to be used: the current implementation focus on server site to build URI to be used in http post/put; not for a simple http get as it is also been used on client site (by browsers, or vaadin apps). Would be fine if we could control the use target from outsite; e.g. as a build() call parameter, or separate buildUrlEncoded() using "%20" and build() use the current implementation?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org