cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Georgiadis ...@k2dyn.com>
Subject REST header case sensitivity in CXF-2.1.2 / Tomcat AJP
Date Fri, 12 Sep 2008 07:38:07 GMT
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/AbstractHTTPDestination.java
   
2008-08-12 23:31:10.000000000 +0300
+++ 
rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.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.java     2008-08-12
23:30:37.000000000 +0300 

+++ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java  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();) {


Mime
View raw message