views:

220

answers:

1

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.

A: 

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.

bkail