tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Header names lower case
Date Mon, 08 Jun 2009 17:54:33 GMT
Alexander Müller wrote:
>> "apparently"? Hm, in this case I'd double-check whether whatever problem
>> you're having is indeed caused by the case of the header names. Just to
>> make sure you're not barking at the wrong tree.
>> If the receiving party is really relying on the case of header names,
>> I'd ask them to fix their broken code.
> 
> Maybe better "definitely" :)
> 
> If I send the headers with the proper capitalisation I get through, otherwise I am getting
an error I wouldnt send the header. Unfortunately this is one of the situations where you
cant ask the other parties to correct their code, but have to adapt by yourself ;).
> 
Just to nitpick, there is no "proper capitalisation", since the RFC says 
that headers are case-insensitive.
Apart from that, I would offer the following subjective advice, in the 
form of suggestions :
- it sounds like you are trying to use Tomcat as some kind of 
transparent proxy here, and maybe in this case Tomcat is not the right 
tool for the job. Maybe you should use some kind of front-end to Tomcat, 
which will catch these requests, and proxy them to the broken back-end, 
instead of trying to do this with Tomcat, which does not really have the 
built-in mechanisms for that kind of thing.
(I'm thinking of Apache httpd, with mod_proxy, mod_rewrite, 
mod_setenvif, mod_perl, etc..)
- you may want to have a look at the urlrewrite filter at www.tuckey.org 
(yes, I know I sound like a salesman for that thing, and I'm starting to 
think I should ask for a commission).  It can check incoming headers, 
and I believe it can delete and/or rewrite some of them before even 
forwarding them to your Tomcat application.
- if you really persist in wanting to do this at the application level, 
I would look at it in another way : rather than trying to be a 
transparent proxy, have your Tomcat application :
   a) receive and process the client request, including the lower-cased 
headers
   b) from your application, issue a brand /new/ HTTP request to the 
broken  back-end, composing the headers that you know it expects.  For 
that, you could use some library like the Apache Commons HTTPClient.
- if your purpose is just to transparently proxy these requests, you 
could also think about issuing a redirect response to the browser, and 
let it deal with it himself.

The problem with trying to modify the Tomcat code for this, is that you 
will set yourself up for all kinds of annoyances, because you cannot 
even be sure how all /your/ different clients may capitalise these 
headers or not when they send the request to you.  So you could be faced 
with having to check if you got a header like "User-Agent" or 
"USER-AGENT" or "user-agent" and so on...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message