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

[jsr339-experts] Re: Malformed media types and status codes

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Mon, 26 Sep 2011 14:52:29 +0100

Hi,

>> On 09/25/2011 11:07 PM, Sergey Beryozkin wrote:
>>> Hi
>>>
>>> I'm wondering, what should the specification say about cases where
>>> HTTP ContentType or Accept contain malformed values.
>>
>> You mean malformed in the sense of not following the definition in
>> HTTP 1.1 spec?
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7
>>
>>>
>>> For example, should
>>>
>>> Accept: text
>>>
>>> result in 406 or 400 ?
>>
>> Depends on the side IMO.
>>
>> It would probably make sense to follow the "be conservative in what
>> you produce" guideline and fail early with an
>> exception on the client side.
>>
>> On the server side, all existing implementations should follow the
>> spec and send back 415 (in case of
>> malformed/unsupported Content-type) or 406 (in case of
>> malformed/unsupported Accept) - as per section 3.7.3, stage 3.a.
>> ...
>
> Malformed != Unsupported.
>
> Malformed should be 400.

I'm fine with 406 though it did seem originally to me that 400 was
possible too. Question is, what are the usual expectations, I tried

curl -H "Accept: bar" www.amazon.com,

did get their HTML page back.

Cheers, Sergey

>
> Best regards, Julian