My understanding - the HTTP spec doesn't ( and can't ) define a complete
list of headers supporting multiple values. That's impossible given that
additional headers are supported.

If the servlet spec requires getHeader() to return the 'concatenated value
for multi-headers' - then the spec can't be implemented.
If it requires getHeaders() to split headers that are multi-value and 
were sent concatenated - it can't be implemented ( and it's an API bug ) 
It can be done only for the list of headers defined in the spec.

Returning whatever was found in the original request is IMO the only
reasonable solution. I doesn't think apache ( or other servers ) 
are spliting/merging received headers either.

The user application should use getHeaders() and split each header ( or 
merge them ) if it knows a header is multi-value. 

Well, there is a trick that can be used in deciding to split/merge:
if the user calls getHeader("Foo"), and we have multiple Foo headers,
then we can concatenate them and return the result.

If the user calls getHeaders("Foo") and we have headers with ',', then
we split them. ( if he would call getHeaders("Date") - it would be 
his error ).

However that's a bad solutuion - many apps call getHeaders() for 
all headers ( like request dump, etc ). 

Costin
  

On Sun, 18 Aug 2002, Steve Downey wrote:

> > > Given:
> > > H:A,B
> > > H:C
> > >
> > > getHeader() should either return ``A'' or ``A,B,C''. Returning ``A,B'',
> > > as it does now, can't be right. It introduces semantic differences
> > > between multiple headers and comma-separated lists where their must be
> > > none.
> >
> > Yes, it is right.
> >
> > Consider:
> > H: A, B
> >
> > In that case, getHeader() has to return "A, B" since it is not known if
> > this header is comma separated, as per the spec definition.
> >
> 
> Ah. That's where we're going in separate directions. I'm assuming that it is 
> known. The HTTP spec defines which headers are comma separated. So it's just 
> a matter of checking against that list in order to know how to treat multiple 
> values. According to the current servlet spec we have to, since we need to 
> parse out the values for headers that are comma separated lists. 
> getHeaders("Date") should not break apart the date into two values.
> 
> > In the case:
> > H: A, B
> > H: C
> >
> > Well, you have multiple choices, all of which are valid.
> > - you may want to return the same thing as above, which means you return
> > "A, B"
> > - you can also return "A"
> >
> > Returning "A, B, C" is incorrect, as you have to return the first value
> > of the header.
> > Since implementing the first option is easier, I'd leave the current
> > behavior.
> >
> > getHeaders indicate that the header is comma separated, so it should be
> > parsed. This is not currently done, but indeed it should be done.
> > Hacking MimeHeaders can result in a correct *and* efficient implementation.
> >
> 
> getHeaders() by itself doesn't tell you that the header is comma separated. 
> getHeaders("Date") should give you "Wed, 15 Nov 1995 06:25:24 GMT", not 
> {"Wed", "15 Nov 1995 06:25:24 GMT"}. 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to