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

[jsr339-experts] Re: Question about HttpHeaders.getRequestHeader

From: Sergey Beryozkin <sberyozkin_at_talend.com>
Date: Tue, 22 Jan 2013 17:36:52 +0000

On 22/01/13 16:55, Julian Reschke wrote:
> On 2013-01-22 17:47, Sergey Beryozkin wrote:
>> Hi
>>
>> Now and then I'm finding I'm not exactly sure what
>> HttpHeaders.getRequestHeader() which returns a list of String is
>> supposed to return for different types of headers, such that it can all
>> be portable.
>>
>> For example, consider these 2 headers:
>>
>>
>> Accept: a/b,c/d
>> Authorization: CustomScheme a=2,b=3,c=4
>>
>> What is the spec-compliant response from
>> HttpHeaders.getRequestHeader() ? :
>>
>> 1. A single value list, with a single value containing "a/b,c/d" for
>> Accept and "CustomScheme a=2,b=3,c=4"
>> 2. List with two values for Accept ("a/b", "c/d") and List with 3 or 4
>> values for Authorization, example ("CustomScheme a=2", "b=3", "c=4")?
>> ...
>
> You can't split on "," unless you exactly know the ABNF of the header
> field.
OK, "CustomScheme a=2,b=3,c=4" is actually a single header value so
splitting it is wrong I guess, I guess it is then unfortunate that for
most other headers where "," actually represents a split character it
won't be processed.

So I'm concluding for now that from the API implementation's point of
view the following is always true:

List<String> values = HttpHeaders.getRequestHeader("a");
assertEquals(1, values.size())
assertEquals(values.get(0), HttpHeaders.getHeaderString("a"));

unless we have:

a: a1
a: a2

I still wonder what HttpHeaders.getRequestHeader("Accept") will return
in Jersey and RestEasy, given "Accept: a/b,c/d"

Thanks, Sergey
>
> Best regards, Julian