dev@jsr311.java.net

Re: Parsing headers, was: Abstract from HTTP <was> Re: Welcome to JSR 311

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 10 Apr 2007 15:32:04 +0200

Julian Reschke wrote:
> Paul Sandoz schrieb:
>> ...
>> Not that in the java doc of the proposal you can achieve the same
>> thing using the HeaderParam annotation:
>>
>> @HeaderParam("Accept") List<String> tags
>>
>> The same rule also works for QueryParam and MatrixParam annotations.
>>
>> Note that the list is not 'normalized' so if there was:
>>
>> Accept: text/html, text/plain
>> Accept: image/gif
>
> So how would you parse something like:
>
> Accept: foo/bar;ext="a,b", text/plain
>

It would have to be done by the developer e.g. in a rather crude way:

    String[] values = header.split(",");


> (as far as I understand, a parser for list-typed headers must understand
> the syntax of each component)
>

Right.

>> Then there would be two values "text/html, text/plain" and
>> "image/gif". Not always ideal...
>>
>> Do you think normalization should be required?
>
> I think it would be desirable...
>

OK. I suppose if you are using the List type then it is correct to
assume that header values can consist of comma separated values.

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109