Hi Sergey,
First, please accept my sincere apologies for not replying, it was an
email management SNAFU on my part. Next time please, metaphorically,
poke me in the ribs, with a direct email if i do not reply in a timely
fashion!
The encoding rules for query parameter name and values are different
to the encoding rules for the query component.
There is a "convention" (well it is defined by the HTTP spec in the
form section) that for query parameter name and values a ' ' character
is encoded as a '+'. That convention should not apply to the encoding
rules of the query component.
Does that help?
Paul.
On Aug 23, 2010, at 11:55 PM, Sergey Beryozkin wrote:
> Hi All
>
> I have to fix a couple of disabled UriBuilder tests which are going
> to block the next CXF release unless fixed and I'm looking at these
> tests and feeling confused :-) given that it's been awhile since I
> was looking into the relevant code.
>
> The question is about dealing with ' ' and '+' in the query
> component of URI.
> I can see two UriBuilder tests adapted from the similar JAXRS TCK
> 1.1 tests, one using the replaceQuery method and the other one -
> queryParam.
>
> One test does uriBuilder.queryParam(name, "x y").build() and
> expects : name=x+y.
> The other one does uriBuilder.replaceQuery("name=x y").build() and
> expects : name=x%20y
>
> I think something is wrong there. Irrespectively of which method is
> used to create a query component, the end result, as far as
> UriBuilder is concerned, should be the same.
>
> Now, I can see another test requirement where we do
>
> uriBuilder.replaceQuery("name=x+y&name=%20").build()
>
> and expect
>
> name=x+y&name=%20
>
> Given the build() leads to encoding % to %25, we need to decode
> "name=x+y&name=%20" first, otherwise we'd get %2520 for the 2nd
> value of name.
>
> Clearly we can not decode '+' to ' ' here otherwise we'd not be able
> to reproduce the original query. Which makes me think that the test
> which expects "x y" be encoded as "x+y" is wrong.
>
> So I'm thinking :
>
> - test that does uriBuilder.queryParam(name, "x y").build() and
> expects : 'name=x+y' is wrong
> - decoding 'x+y' to 'x y' is not required
>
> Is it correct ?
>
> Any clarifications will be appreciated
> cheers, Sergey
>
>
>
>
>