camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r908517 - in /camel/trunk/components/camel-http/src: main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
Date Wed, 10 Feb 2010 14:29:26 GMT
Author: davsclaus
Date: Wed Feb 10 14:29:25 2010
New Revision: 908517

URL: http://svn.apache.org/viewvc?rev=908517&view=rev
Log:
CAMEL-2452: Filter general http headers. Thanks to Christian Mueller for the patch.

Added:
    camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
  (with props)
Modified:
    camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java

Modified: camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java?rev=908517&r1=908516&r2=908517&view=diff
==============================================================================
--- camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
(original)
+++ camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java
Wed Feb 10 14:29:25 2010
@@ -32,14 +32,14 @@
         getOutFilter().add("content-type");
         // Add the filter for the Generic Message header
         // http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.5
-        getOutFilter().add("Cache-Control");
-        getOutFilter().add("Connection");
-        getOutFilter().add("Pragma");
-        getOutFilter().add("Trailer");
-        getOutFilter().add("Transfer-Encoding");
-        getOutFilter().add("Upgrade");
-        getOutFilter().add("Via");
-        getOutFilter().add("Warning");
+        getOutFilter().add("cache-control");
+        getOutFilter().add("connection");
+        getOutFilter().add("pragma");
+        getOutFilter().add("trailer");
+        getOutFilter().add("transfer-encoding");
+        getOutFilter().add("upgrade");
+        getOutFilter().add("via");
+        getOutFilter().add("warning");
         
         setLowerCase(true);
         

Added: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java?rev=908517&view=auto
==============================================================================
--- camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
(added)
+++ camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
Wed Feb 10 14:29:25 2010
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class HttpHeaderFilterStrategyTest extends CamelTestSupport {
+
+    private HttpHeaderFilterStrategy filter;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        filter = new HttpHeaderFilterStrategy();
+        exchange = new DefaultExchange(new DefaultCamelContext());
+    }
+
+    @Test
+    public void applyFilterToExternalHeaders() {
+        assertFalse(filter.applyFilterToExternalHeaders("content-length", 10, exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Content-Length", 10, exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("content-type", "text/xml", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Content-Type", "text/xml", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("cache-control", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Cache-Control", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("connection", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Connection", "close", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("pragma", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Pragma", "no-cache", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("trailer", "Max-Forwards", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Trailer", "Max-Forwards", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("transfer-encoding", "chunked", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Transfer-Encoding", "chunked", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("upgrade", "HTTP/2.0", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Upgrade", "HTTP/2.0", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("via", "1.1 nowhere.com", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Via", "1.1 nowhere.com", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("warning", "199 Miscellaneous warning",
exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("Warning", "199 Miscellaneous warning",
exchange));
+
+        assertFalse(filter.applyFilterToExternalHeaders("CamelHeader", "test", exchange));
+        assertFalse(filter.applyFilterToExternalHeaders("org.apache.camel.header", "test",
exchange));
+
+        assertFalse(filter.applyFilterToExternalHeaders("notFilteredHeader", "test", exchange));
+    }
+
+    @Test
+    public void applyFilterToCamelHeaders() {
+        assertTrue(filter.applyFilterToCamelHeaders("content-length", 10, exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Content-Length", 10, exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("content-type", "text/xml", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Content-Type", "text/xml", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("cache-control", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Cache-Control", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("connection", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Connection", "close", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("pragma", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Pragma", "no-cache", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("trailer", "Max-Forwards", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Trailer", "Max-Forwards", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("transfer-encoding", "chunked", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Transfer-Encoding", "chunked", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("upgrade", "HTTP/2.0", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Upgrade", "HTTP/2.0", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("via", "1.1 nowhere.com", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Via", "1.1 nowhere.com", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("warning", "199 Miscellaneous warning",
exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("Warning", "199 Miscellaneous warning",
exchange));
+
+        assertTrue(filter.applyFilterToCamelHeaders("CamelHeader", "test", exchange));
+        assertTrue(filter.applyFilterToCamelHeaders("org.apache.camel.header", "test", exchange));
+
+        assertFalse(filter.applyFilterToCamelHeaders("notFilteredHeader", "test", exchange));
+    }
+
+}

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-http/src/test/java/org/apache/camel/component/http/HttpHeaderFilterStrategyTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message