REST header case sensitivity in CXF-2.1.2 / Tomcat AJP
------------------------------------------------------

                 Key: CXF-1795
                 URL: https://issues.apache.org/jira/browse/CXF-1795
             Project: CXF
          Issue Type: Bug
    Affects Versions: 2.1.2
         Environment: Apache-2.2, Tomcat-6.0.18, mod_jk-1.2.26
            Reporter: John Georgiadis


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. The Tomcat HTTP connector also works 
with the patch.

I'm not sure whether other code paths are affected by the change in 
AbstractHTTPDestination, however the line after the modified code:
String mappedName = HttpHeaderHelper.getHeaderKey(fname);
already maps common upper-case headers to lower-case (except Authentication).


--- 
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();) { 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to