cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Kulp <dk...@apache.org>
Subject Re: REST header case sensitivity in CXF-2.1.2 / Tomcat AJP
Date Fri, 12 Sep 2008 16:38:09 GMT
On Friday 12 September 2008 5:30:18 am Sergey Beryozkin wrote:
> Hi John
>
> Thanks for posting the patch details - can you please create a JIRA and
> attach the patch to it ?
>
> The patch seems ok - but I'm wondering if there're any other code paths
> which might be affected by the change in the AbstractHttpConnector, say in
> the JAX-WS runtime ? Does your code works ok with this change and Tomcat's
> HTTP Connector ?

Well, yes and no.    Some versions of Tomcat make everything lowercase.   We 
hit that with basic auth when trying to find the "Authorization" header and 
we just got a bug related to it an SOAPAction:
https://issues.apache.org/jira/browse/CXF-1797
Jetty, on the other hand, leaves the header names as is.

I'd definitely be OK with lowercasing them all to make them consistent 
PROVIDING the tests all pass.    If you do so, we should probably then update 
the HttpHeaderHelper.   If all the strings are already lowercase, we could 
get rid of some of the mapped keys in there.

Dan



>
> Cheers, Sergey
>
> ----- Original Message -----
> From: "John Georgiadis" <ig@k2dyn.com>
> To: <issues@cxf.apache.org>
> Sent: Friday, September 12, 2008 8:38 AM
> Subject: REST header case sensitivity in CXF-2.1.2 / Tomcat AJP
>
> > HeaderParam labels in CXF-2.1.2 REST seem to be case sensitive. The
> > problem appears only when using Tomcat-6.0.18 through its AJP connector.
> > It does not appear when Tomcat is accessed through its HTTP connector.
> > mod_jk (1.2.26) is passing headers unmodified to AJP, so differences in
> > AJP & HTTP connectors make this issue manifest.
> >
> > The following patch fixed the bug for us. Please have a look and comment:
> >
> > ---
> > rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHT
> >TPDestination.java 2008-08-12 23:31:10.000000000 +0300
> > +++
> > rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHT
> >TPDestination.java 2008-09-11 21:31:56.000000000 +0300
> > @@ -190,7 +190,7 @@
> >        HttpServletRequest req =
> > (HttpServletRequest)message.get(HTTP_REQUEST);
> >        //TODO how to deal with the fields
> >        for (Enumeration e = req.getHeaderNames(); e.hasMoreElements();) {
> > -            String fname = (String)e.nextElement();
> > +            String fname = ((String)e.nextElement()).toLowerCase();
> >            String mappedName = HttpHeaderHelper.getHeaderKey(fname);
> >            List<String> values;
> >            if (headers.containsKey(mappedName)) {
> >
> > ---
> > rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.jav
> >a     2008-08-12 23:30:37.000000000 +0300
> >
> > +++
> > rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.jav
> >a  2008-09-11 21:29:53.000000000 +0300
> >
> > @@ -449,7 +449,7 @@
> >    private static Object processHeaderParam(Message m, String header,
> >                                             Class<?> pClass, Type
> > genericType, String defaultValue) {
> >
> >        Map<String, List<String>> headers = (Map<String,
> > List<String>>)m.get(Message.PROTOCOL_HEADERS);
> >
> > -        List<String> values = headers.get(header);
> > +        List<String> values = headers.get(header.toLowerCase());
> >        StringBuilder sb = new StringBuilder();
> >        if (values != null) {
> >            for (Iterator<String> it = values.iterator(); it.hasNext();) {
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland



-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Mime
View raw message