Does UriBuilder incorrectly encode the value of a query parameter?

Let's look at the following code example in which the path and the only parameter are encoded ...

Parameter Name: "param"

Parameter value: "foo / bar? Aaa = bbb & ccc = ddd" (this is a URL with request parameters)

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

The returned string of the encoded URL:

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

Is it correct?

Should the character "&" (and maybe even "?") Be encoded in the parameter value string?

Will the display URL be interpreted as follows:

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

+3
1

"fromPath" , , "fromUri". ...

?

, .

"&" ( "?" ) ?

, .

URL- :

, name= "param", value = "ar? aaa% 3Dbbb", , name= "ccc% 3Dddd", .

"foo/bar? aaa = bbb", , . javax.ws.rs.core.

+1

Source: https://habr.com/ru/post/1745003/


All Articles