You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Waldhoff, Rodney" <rw...@us.britannica.com> on 2002/02/21 18:46:20 UTC

HTTP Headers [was RE: Commons Util 1.0 release candidate 1]

> the "header" stuff could be done simply 
> with a case-insensitive comparision due 
> to different containers using either 
> "-" or "_" to seperate header names. 

But "User-Agent" and "User_Agent" are different headers (while "UsEr-AgEnT",
"USER-AGENT", and "user-agent" are the the same) per the HTTP spec, yes?  If
the container is sending "Content_Length" when it means "Content-Length",
that's a bug in the container, yes?

(This isn't just academic interest, if I'm misunderstanding the situation
here, or if there is a common if invalid case here, we should consider it
for Http Client.)

Re: HTTP Headers [was RE: Commons Util 1.0 release candidate 1]

Posted by Lavandowska <fl...@yahoo.com>.
--- Lavandowska <fl...@yahoo.com> wrote:
> I've always considered "User-Agent" and "User_Agent" to be the same
> header.  I've never checked any specs to see if the header should be
> done one way or the other.  All I know is that there is *NO*
> consistency between containers, thus I couldn't ever write
> getHeader("User-Agent") and be certain that it will migrate well from
> one container to another.  In fact, this is exactly the problem that
> lead to this solution.

To be specific, it was "referer" that caused the whole thing, I've had
to use getHeader() with: "REFERER", "referer", "Referer", and
"Http-Referer".

As this violates the spec (case shouldn't matter), should I submit a
version that just deals with the dash vs. underscore matter?

Lance

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HTTP Headers [was RE: Commons Util 1.0 release candidate 1]

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 21 Feb 2002, Lavandowska wrote:

> Date: Thu, 21 Feb 2002 11:33:38 -0800 (PST)
> From: Lavandowska <fl...@yahoo.com>
> Reply-To: Jakarta Commons Developers List <co...@jakarta.apache.org>,
>      flanandowska@yahoo.com
> To: Jakarta Commons Developers List <co...@jakarta.apache.org>
> Subject: Re: HTTP Headers [was RE: Commons Util 1.0 release candidate 1]
>
>
> --- "Waldhoff, Rodney" <rw...@us.britannica.com> wrote:
> > > the "header" stuff could be done simply
> > > with a case-insensitive comparision due
> > > to different containers using either
> > > "-" or "_" to seperate header names.
> >
> > But "User-Agent" and "User_Agent" are different headers (while
> > "UsEr-AgEnT",
> > "USER-AGENT", and "user-agent" are the the same) per the HTTP spec,
> > yes?  If
> > the container is sending "Content_Length" when it means
> > "Content-Length",
> > that's a bug in the container, yes?
>
> I've always considered "User-Agent" and "User_Agent" to be the same
> header.  I've never checked any specs to see if the header should be
> done one way or the other.  All I know is that there is *NO*
> consistency between containers, thus I couldn't ever write
> getHeader("User-Agent") and be certain that it will migrate well from
> one container to another.  In fact, this is exactly the problem that
> lead to this solution.
>
> I hadn't read the Servlet spec closely enough to realize getHeader() is
> supposed to be case-agnostic, otherwise I would have reported a bug
> against the particular containers where it was a problem.  (I don't use
> them anymore anyway).
>

This is actually defined in the HTTP spec, which servlets depend on.

Per RFC 2616, Section 4.2, header names are case insensitive.  However,
that does *not* mean that "-" and "_" are interchangeable -- only letters
have cases.

Per RFC 2616, Section 14.43, the correct header is "User-Agent".



> Lance
>

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: HTTP Headers [was RE: Commons Util 1.0 release candidate 1]

Posted by Lavandowska <fl...@yahoo.com>.
--- "Waldhoff, Rodney" <rw...@us.britannica.com> wrote:
> > the "header" stuff could be done simply 
> > with a case-insensitive comparision due 
> > to different containers using either 
> > "-" or "_" to seperate header names. 
> 
> But "User-Agent" and "User_Agent" are different headers (while
> "UsEr-AgEnT",
> "USER-AGENT", and "user-agent" are the the same) per the HTTP spec,
> yes?  If
> the container is sending "Content_Length" when it means
> "Content-Length",
> that's a bug in the container, yes?

I've always considered "User-Agent" and "User_Agent" to be the same
header.  I've never checked any specs to see if the header should be
done one way or the other.  All I know is that there is *NO*
consistency between containers, thus I couldn't ever write
getHeader("User-Agent") and be certain that it will migrate well from
one container to another.  In fact, this is exactly the problem that
lead to this solution.

I hadn't read the Servlet spec closely enough to realize getHeader() is
supposed to be case-agnostic, otherwise I would have reported a bug
against the particular containers where it was a problem.  (I don't use
them anymore anyway).

Lance

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>