tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: mod_jk codepage in header values
Date Wed, 20 Jan 2010 19:47:17 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mirko,

On 1/20/2010 9:42 AM, Mirko Solic wrote:
> for connecting tomcat with apache i'm using mod_jk connector. But i'm
> having problem with header values. On apache side headers values are in
> UTF-8 cp but on tomcat side i have to make conversion from latin-1 cp.

Hmm.

HTTP defines header values as ASCII (well, it inherits that from other
RFCs, but, whatever). If you need to encode non-ASCII data in header
values, you'll need to do it in such a way that your client understands
them. Often, URL-encoding (aka %-encoding) is used in these situations.

> I'm using this code:
> 
> for(Enumeration en = request.getHeaderNames(); en.hasMoreElements();){
>         header = new Header();
>         headerName = (String) en.nextElement();
>         header.setHeaderName(headerName);
>         header.setHeaderValue(new
> String(request.getHeader(headerName).getBytes("ISO-8859-1")));        

For most values, this will work. On the other hand, the response already
knows how to convert a String into ASCII, so you probably don't have to
do this.

>         headers.add(header);    
> 
>         header = new Header();
>         header.setHeaderName(headerName);
>         header.setHeaderValue(request.getHeader(headerName));
>         headers.add(header);
> }

The "Header" class is not part of the Servlet API. What does all of this do?

> Is it possible to configure mod_jk somehow so that this conversion would
> be no longer needed?

I don't believe so. mod_jk simply moves bytes back and forth across the
wire. There is little to no interference with the HTTP protocol.

What information are you passing through the HTTP headers that needs to
be in a particular encoding? These issues are typically handled using
the response body coupled with a Content-Type header which specifies a
character encoding.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktXXcUACgkQ9CaO5/Lv0PD5ywCgnzBVvS4a1u1wIpb065Z+ALpS
IDUAnjomSUwNPMcpX2lTe08ytExsJ46G
=V2Cz
-----END PGP SIGNATURE-----

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


Mime
View raw message