camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1187385 - in /camel/branches/camel-2.7.x: ./ components/camel-jetty/src/main/java/org/apache/camel/component/jetty/ components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/
Date Fri, 21 Oct 2011 15:03:04 GMT
Author: ningjiang
Date: Fri Oct 21 15:03:03 2011
New Revision: 1187385

URL: http://svn.apache.org/viewvc?rev=1187385&view=rev
Log:
Merged revisions 1187226 via svnmerge from 
https://svn.apache.org/repos/asf/camel/branches/camel-2.8.x

........
  r1187226 | davsclaus | 2011-10-21 17:03:24 +0800 (Fri, 21 Oct 2011) | 1 line
  
  CAMEL-4571: Jetty producer now supports Content-Type header having quotes arond the charset
value.
........

Added:
    camel/branches/camel-2.7.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerContentTypeEncodingInQuoteTest.java
      - copied unchanged from r1187226, camel/branches/camel-2.8.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerContentTypeEncodingInQuoteTest.java
Modified:
    camel/branches/camel-2.7.x/   (props changed)
    camel/branches/camel-2.7.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java

Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Oct 21 15:03:03 2011
@@ -1,2 +1,2 @@
-/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598
-/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597
+/camel/branches/camel-2.8.x:1170965,1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226
+/camel/trunk:1146608,1146903,1147216,1170956,1171396,1174565,1175321,1176274,1176781-1176782,1177394,1177945,1177948,1180597,1187221

Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Oct 21 15:03:03 2011
@@ -1 +1 @@
-/camel/branches/camel-2.8.x:1-1146127,1146608,1146653,1146771,1146903,1147216,1170965-1171083,1171085-1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598
+/camel/branches/camel-2.8.x:1-1146127,1146608,1146653,1146771,1146903,1147216,1170965-1171083,1171085-1171400,1174571,1175323,1176329,1176787,1177397,1177946,1177949,1180598,1187226

Modified: camel/branches/camel-2.7.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java?rev=1187385&r1=1187384&r2=1187385&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
(original)
+++ camel/branches/camel-2.7.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyContentExchange.java
Fri Oct 21 15:03:03 2011
@@ -28,11 +28,14 @@ import org.apache.camel.CamelExchangeExc
 import org.apache.camel.Exchange;
 import org.apache.camel.ExchangeTimedOutException;
 import org.apache.camel.util.IOHelper;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
 import org.eclipse.jetty.client.ContentExchange;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.client.HttpExchange;
 import org.eclipse.jetty.http.HttpHeaders;
 import org.eclipse.jetty.io.Buffer;
+import org.eclipse.jetty.io.ByteArrayBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,12 +68,34 @@ public class JettyContentExchange extend
 
     @Override
     protected void onResponseHeader(Buffer name, Buffer value) throws IOException {
+        String k = name.toString();
+        String v = value.toString();
+        LOG.trace("onResponseHeader {} -> {}", k, v);
+
+        // need to remove quotes from charset which can be returned by some http servers
+        if (Exchange.CONTENT_TYPE.equalsIgnoreCase(k)) {
+            String charset = ObjectHelper.after(v, "charset=");
+            if (charset != null) {
+                charset = charset.trim();
+                String s = StringHelper.removeLeadingAndEndingQuotes(charset);
+                if (!charset.equals(s)) {
+                    v = ObjectHelper.before(v, "charset=") + "charset=" + s;
+                    LOG.debug("Removed quotes from charset in " + Exchange.CONTENT_TYPE +
" from {} to {}", charset, s);
+
+                    // use a new buffer to adjust the value
+                    value = new ByteArrayBuffer.CaseInsensitive(v);
+                }
+            }
+        }
+
         super.onResponseHeader(name, value);
-        headers.put(name.toString(), value.toString());
+        headers.put(k, v);
     }
 
     @Override
     protected void onRequestComplete() throws IOException {
+        LOG.trace("onRequestComplete");
+
         // close the input stream when its not needed anymore
         InputStream is = getRequestContentSource();
         if (is != null) {
@@ -80,6 +105,8 @@ public class JettyContentExchange extend
 
     @Override
     protected void onResponseComplete() throws IOException {
+        LOG.trace("onResponseComplete");
+
         try {
             super.onResponseComplete();
         } finally {
@@ -89,6 +116,8 @@ public class JettyContentExchange extend
 
     @Override
     protected void onExpire() {
+        LOG.trace("onExpire");
+
         try {
             super.onExpire();
         } finally {
@@ -98,6 +127,8 @@ public class JettyContentExchange extend
 
     @Override
     protected void onException(Throwable ex) {
+        LOG.trace("onException {}", ex);
+
         try {
             super.onException(ex);
         } finally {
@@ -107,6 +138,8 @@ public class JettyContentExchange extend
 
     @Override
     protected void onConnectionFailed(Throwable ex) {
+        LOG.trace("onConnectionFailed {}", ex);
+
         try {
             super.onConnectionFailed(ex);
         } finally {



Mime
View raw message