cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sergey.beryoz...@iona.com>
Subject Re: REST header case sensitivity in CXF-2.1.2 / Tomcat AJP
Date Fri, 12 Sep 2008 09:30:18 GMT
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 ? 

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

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Mime
View raw message