On Jan 30, 2009, at 11:33 PM, Marc Hadley wrote:
> On Jan 30, 2009, at 4:46 PM, Farrukh Najmi wrote:
>>
>> BTW, do you have an opinion on use of a format QueryParam vs,
>> request header. The latter seems the more RESTFul approach but I am
>> not sure how a human user can specify request header in a URL.
>
> Right. The Accept header is the HTTP way of specifying the desired
> format but browsers don't normally give you the option of specifying
> an accept unless you are using something like the Poster plug-in for
> Firefox.
>
>> Is there a standard mechanism for encoding HTTP request header
>> param values within a URL? If not, and if I need a human to be able
>> to specify format in a web browser then it seems the format
>> QueryParam is my best option.
>>
> There's no standard mechanism but there are some conventions. E.g.
> Rails uses file extensions like .xml on the end of the URL. We had
> some support for that kind of extension-based conneg in pre-1.0 JAX-
> RS but Roy Fielding persuaded us that it was a bad idea to include
> this in the spec, see the following message and the rest of the
> thread for an idea of the tradeoffs:
>
> https://jsr311.dev.java.net/servlets/ReadMsg?list=dev&msgNo=1458
>
> IIRC, Jersey still supports this functionality as an extension
> however.
>
It does. One currently needs to extend a ResourceConfig implementation
and set a map of extension to media type. I am not satisfied with that
approach and it would be better to support a filter for URI path
extensions or a query parameter as you mention below.
Farrukh, if you want this functionality could you log an issue?
Paul.
> If using a query parameter, one approach is to deploy a filter
> (Servlet or Jersey) that extracts the value of the query parameter
> and uses it to override the Accept header in the request. Then you
> can code your JAX-RS application as if Accept were always used and
> have the filter do a bit of pre-processing when URL-based conneg is
> used.
>
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>