servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r726716 - in /servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints: AbstractHttpProviderMarshaler.java HttpSoapProviderMarshaler.java
Date Mon, 15 Dec 2008 15:42:31 GMT
Author: gnodet
Date: Mon Dec 15 07:42:31 2008
New Revision: 726716

URL: http://svn.apache.org/viewvc?rev=726716&view=rev
Log:
SM-1733: servicemix-http provider endpoint may convey incorrect http headers, leading to problems

Modified:
    servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/AbstractHttpProviderMarshaler.java
    servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java

Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/AbstractHttpProviderMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/AbstractHttpProviderMarshaler.java?rev=726716&r1=726715&r2=726716&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/AbstractHttpProviderMarshaler.java
(original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/AbstractHttpProviderMarshaler.java
Mon Dec 15 07:42:31 2008
@@ -23,16 +23,35 @@
 import java.io.BufferedInputStream;
 import java.util.zip.GZIPOutputStream;
 import java.util.zip.GZIPInputStream;
+import java.util.Arrays;
+import java.util.Set;
+import java.util.HashSet;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.mortbay.jetty.HttpHeaders;
 
 public abstract class AbstractHttpProviderMarshaler implements HttpProviderMarshaler {
 
     private final Log log = LogFactory.getLog(getClass());
 
+    private static final Set<String> DEFAULT_HEADER_BLACKLIST =
+            new HashSet<String>(
+                Arrays.asList(HttpHeaders.AUTHORIZATION,
+                              HttpHeaders.EXPECT,
+                              HttpHeaders.FORWARDED,
+                              HttpHeaders.FROM,
+                              HttpHeaders.HOST,
+                              HttpHeaders.CONTENT_ENCODING,
+                              HttpHeaders.CONTENT_TYPE));
+
     private String contentEncoding;
     private String acceptEncoding;
+    /**
+     * a blacklist for properties which shouldn't be copied
+     */
+    private Set<String> headerBlackList = DEFAULT_HEADER_BLACKLIST;
+
 
     public String getContentEncoding() {
         return contentEncoding;
@@ -70,4 +89,26 @@
         }
     }
 
+    /**
+     * checks if a property is on black list
+     *
+     * @param name the property
+     * @return true if on black list
+     */
+    protected boolean isBlackListed(String name) {
+        return (this.headerBlackList != null && this.headerBlackList.contains(name));
+    }
+
+    public Set<String> getHeaderBlackList() {
+        return headerBlackList;
+    }
+
+    /**
+     * Specifies a list of headers to not include in the HTTP request.
+     * 
+     * @param headerBlackList list of headers to not include in the HTTP request
+     */
+    public void setHeaderBlackList(Set<String> headerBlackList) {
+        this.headerBlackList = headerBlackList;
+    }
 }

Modified: servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java?rev=726716&r1=726715&r2=726716&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
(original)
+++ servicemix/components/bindings/servicemix-http/trunk/src/main/java/org/apache/servicemix/http/endpoints/HttpSoapProviderMarshaler.java
Mon Dec 15 07:42:31 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.servicemix.http.endpoints;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -32,7 +31,6 @@
 import org.apache.servicemix.soap.api.Message;
 import org.apache.servicemix.soap.api.Policy;
 import org.apache.servicemix.soap.api.model.Binding;
-import org.apache.servicemix.soap.bindings.soap.SoapConstants;
 import org.apache.servicemix.soap.interceptors.jbi.JbiConstants;
 import org.apache.servicemix.soap.interceptors.xml.StaxInInterceptor;
 import org.mortbay.io.ByteArrayBuffer;
@@ -109,7 +107,9 @@
         httpExchange.setURL(baseUrl);
         httpExchange.setRequestContent(new ByteArrayBuffer(baos.toByteArray()));
         for (Map.Entry<String,String> entry : msg.getTransportHeaders().entrySet())
{
-            httpExchange.addRequestHeader(entry.getKey(), entry.getValue());
+            if (!isBlackListed(entry.getKey())) {
+                httpExchange.addRequestHeader(entry.getKey(), entry.getValue());
+            }
         }
         /*
         httpExchange.setRequestEntity(new Entity() {



Mime
View raw message