dev@glassfish.java.net

Re: REST API and slashes in resource names

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Fri, 04 Jun 2010 10:31:26 +0200

On Jun 3, 2010, at 7:18 PM, Bruno Harbulot wrote:

> Hi,
>
> On 01/06/10 17:23, Paul Sandoz wrote:
>
>>>>
>>>> So how about wrapping resource values that contain "reserved"
>>>> characters
>>>> by a pair of (unreserved) "normal" brackets '(' and ')'?
>>>
>>> I'm not sure whether you want to take more recent RFCs into
>>> consideration, but in RFC 3986, which obsoletes RFC 2389,
>>
>> Good point. I was using the URI spec that is referenced by HTTP 1.1
>> (maybe the work on tidying up the HTTP spec will update the
>> reference?)
>>
>>
>>> parentheses are reserved characters:
>>>
>>> http://tools.ietf.org/html/rfc3986#section-2.2
>>>
>>> Section 2.4 is probably relevant to this discussion too (especially
>>> its last sentence).
>>>
>>
>> I am not sure what the last sentence actually means in terms of
>> parsing
>> a URI :-) but i strongly suspect for HTTP schemes and the path
>> component
>> that '(' and ')' are OK. Jersey does not encode such characters
>> when URI
>> building path components e.g.:
>
> I don't know JAX-RS well enough (I must admit I tend to use Restlet,
> without its JAX-RS extension), but I've just had a quick look at its
> specifications. Both specifications (1.0 and 1.1) refer to RFC 3986
> for the URI syntax (section 3.7 for example).
>
> It sounds like the fact Jersey uses '(' and ')' (non-encoded) could
> be a bug there.
>

Section 2.4 states:

   "URI producing applications should percent-encode data octets that
correspond to characters in the reserved set unless
    these characters are specifically allowed by the URI scheme to
represent data in that component"

The "sub-delims" set of characters are specifically allowed in the
path component of a URI.

   http://greenbytes.de/tech/webdav/rfc3986.html#path
    pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

Paul.