jsr339-experts@jax-rs-spec.java.net

[jsr339-experts] Re: UriBuilder.segment and build with encodePathSlash

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Mon, 22 Oct 2012 16:07:23 +0100

On 22/10/12 13:43, Marek Potociar wrote:
>
> On Oct 22, 2012, at 1:26 PM, Sergey Beryozkin<sberyozkin_at_talend.com> wrote:
>
>> I know that I'm the last one who still does not get it :-).
>>
>> Consider the following:
>>
>> uriBuilder.fromPath("http://localhost").segment("{a}").build("a/b", false);
>>
>> UriBuilder.segment() states that "/" have to be encoded.
>
> The javadoc of segment() applies to the value passed to the segment(). Not to a template that was added via segment(). IOW, if you passed "a/b" into segment() directly, it would be encoded.

So, to be absolutely clear.

By default, irrespectively of whether a given template var was
introduced as part of path() or segment() call, the "/" (inside of this
var's content) is never supposed to be encoded.

The only way to override it, when working with build(), is to use a new
flag.


>
>> So one possible output is:
>>
>> "http://localhost/a%2Fb"
>>
>> While build() requires this slash to be left as is.
>
>>
>> So the result is then:
>>
>> "http://localhost/a/b"
>>
>> If the last output is the right one (has to be really), then I guess
>>
>> UriBuilder.segment() docs can be improved a bit to state that only "/" in the literal expressions have to be encoded by default, otherwise the encoding is affected by the new build flag, similarly the same clarification needs to be applied to UriBuilder path docs
>
> Can you please provide a javadoc version that would clarify the segment() behavior in a way that is, in your opinion, clear& understandable?
>
Sure, can do that once I'm 100% clear

thanks, Sergey

> Thanks,
> Marek
>
>>
>> Sergey
>>
>>
>