UriBuilder incorrectly encoding Query Parameters value ?

Posted by Fred on Stack Overflow See other posts from Stack Overflow or by Fred
Published on 2010-05-11T20:30:31Z Indexed on 2010/05/11 20:34 UTC
Read the original article Hit count: 411

Filed under:
|
|

Lets consider the following code sample where a path and single parameter are encoded...

Parameter name: "param"

Parameter value: "foo/bar?aaa=bbb&ccc=ddd" (happens to be a url with query parameters)

   String test = UriBuilder.fromPath("https://dummy.com").
               queryParam("param", "foo/bar?aaa=bbb&ccc=ddd").
               build().toURL().toString();

The encoded URL string returned is:

 "https://dummy.com?param=foo/bar?aaa%3Dbbb&ccc%3Dddd"

Is this correct ?

Should not the character "&" (and may be even "?") be encoded in the parameter value string ?

Would not the URL produced be interpreted as follow:

One first parameter, name="param", value = "ar?aaa%3Dbbb" followed by a second parameter, name="ccc%3Dddd", without value.

© Stack Overflow or respective owner

Related posts about java

Related posts about query-parameters