dev@jsr311.java.net

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

From: Julian Reschke <julian.reschke_at_gmx.de>
Date: Tue, 10 Apr 2007 14:50:15 +0200

Paul Sandoz schrieb:
> ...
>> 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(",");

But that would yield an incorrect result.

>> (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.

I'm not sure what you're saying here. To re-iterate what I was *trying*
to say...:

- we should make it easy to properly handle list-typed headers

- there's no *generic* way to do that

- thus we should allow the API client to specify a micro-parser for each
list item, and provide predefined parsers for things like etags,
content-types etc.

Best regards, Julian