开发者

UriBuilder incorrectly encoding Query Parameters value?

开发者 https://www.devze.com 2022-12-30 03:27 出处:网络
Lets consider the following code sample where a path and single parameter are encoded... Parameter name:\"param\"

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 e开发者_开发问答ncoded 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.


Your initial call to "fromPath" should probably be "fromUri". That said...

Is this correct ?

No, it does not look like correct output.

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

Yes, it should be.

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.

The first parameter would be "foo/bar?aaa=bbb", but yes, you're interpreting properly. This looks like a bug in your javax.ws.rs.core provider.

0

精彩评论

暂无评论...
验证码 换一张
取 消