cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r775952 - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/helpers/ rt/transports/http/src/main/java/org/apache/cxf/transport/http/
Date Mon, 18 May 2009 13:56:58 GMT
Author: dkulp
Date: Mon May 18 13:56:57 2009
New Revision: 775952

URL: http://svn.apache.org/viewvc?rev=775952&view=rev
Log:
Merged revisions 774979 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r774979 | dkulp | 2009-05-14 21:15:30 -0400 (Thu, 14 May 2009) | 2 lines
  
  [CXF-2215] Don't rely on getCharacterEncoding, parse from Content-Type.  May fix CXF-2215
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon May 18 13:56:57 2009
@@ -1 +1 @@
-/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851
+/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101,766763,766770,766860,766962-766963,767159,767191,767927,771416,772143,772402,772658,772714,773009-773010,773027,773049,773146,773581,773691,773693,774446-774496,774558,774760,774851,774979

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java?rev=775952&r1=775951&r2=775952&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
Mon May 18 13:56:57 2009
@@ -74,6 +74,24 @@
         }
     }
     
+    public static String findCharset(String contentType) {
+        if (contentType == null) {
+            return null;
+        }
+        int idx = contentType.indexOf("charset=");
+        if (idx != -1) {
+            String charset = contentType.substring(idx + 8);
+            if (charset.indexOf(";") != -1) {
+                charset = charset.substring(0, charset.indexOf(";")).trim();
+            }
+            if (charset.charAt(0) == '\"') {
+                charset = charset.substring(1, charset.length() - 1);
+            }
+            return charset;
+        }
+        return null;
+    }
+    
     //helper to map the charsets that various things send in the http Content-Type header

     //into something that is actually supported by Java and the Stax parsers and such.
     public static String mapCharset(String enc) {

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=775952&r1=775951&r2=775952&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Mon May 18 13:56:57 2009
@@ -273,9 +273,13 @@
         }
         inMessage.put(Message.PATH_INFO, contextPath + req.getPathInfo());
         
+        String contentType = req.getContentType();
+        String enc = HttpHeaderHelper.findCharset(contentType);
+        if (enc == null) {
+            enc = req.getCharacterEncoding();
+        }
         // work around a bug with Jetty which results in the character
         // encoding not being trimmed correctly.
-        String enc = req.getCharacterEncoding();
         if (enc != null && enc.endsWith("\"")) {
             enc = enc.substring(0, enc.length() - 1);
         }
@@ -290,7 +294,7 @@
         inMessage.put(Message.ENCODING, normalizedEncoding);
         
         inMessage.put(Message.QUERY_STRING, req.getQueryString());
-        inMessage.put(Message.CONTENT_TYPE, req.getContentType());
+        inMessage.put(Message.CONTENT_TYPE, contentType);
         inMessage.put(Message.ACCEPT_CONTENT_TYPE, req.getHeader("Accept"));
         String basePath = getBasePath(contextPath);
         if (!StringUtils.isEmpty(basePath)) {

Modified: cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=775952&r1=775951&r2=775952&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Mon May 18 13:56:57 2009
@@ -2094,14 +2094,7 @@
             inMessage.put(Message.RESPONSE_CODE, responseCode);
             String ct = connection.getContentType();
             inMessage.put(Message.CONTENT_TYPE, ct);
-            String charset = null;
-            if (ct != null 
-                && ct.indexOf("charset") != -1) {
-                charset = ct.substring(ct.indexOf("charset") + 8);
-                if (charset.indexOf(";") != -1) {
-                    charset = charset.substring(0, charset.indexOf(";"));
-                }
-            }
+            String charset = HttpHeaderHelper.findCharset(ct);
             String normalizedEncoding = HttpHeaderHelper.mapCharset(charset);
             if (normalizedEncoding == null) {
                 String m = new org.apache.cxf.common.i18n.Message("INVALID_ENCODING_MSG",



Mime
View raw message