You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/09/14 12:34:21 UTC

svn commit: r814567 - in /camel/trunk/components: camel-http/src/main/java/org/apache/camel/component/http/HttpHeaderFilterStrategy.java camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.java

Author: davsclaus
Date: Mon Sep 14 10:34:21 2009
New Revision: 814567

URL: http://svn.apache.org/viewvc?rev=814567&view=rev
Log:
CAMEL-1977: Http based components should filter out camel internal headers.

Added:
    camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.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=814567&r1=814566&r2=814567&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 Mon Sep 14 10:34:21 2009
@@ -45,6 +45,7 @@
         setLowerCase(true);
         
         // filter headers begin with "Camel" or "org.apache.camel"
-        setOutFilterPattern("(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
+        // must ignore case for Http based transports
+        setOutFilterPattern("(?i)(Camel|org\\.apache\\.camel)[\\.|a-z|A-z|0-9]*");
     }
 }

Added: camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.java?rev=814567&view=auto
==============================================================================
--- camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.java (added)
+++ camel/trunk/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpFilterCamelHeadersTest.java Mon Sep 14 10:34:21 2009
@@ -0,0 +1,80 @@
+/**
+ * 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.jetty;
+
+import java.util.Map;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * @version $Revision$
+ */
+public class HttpFilterCamelHeadersTest extends CamelTestSupport {
+
+    @Test
+    public void testFilterCamelHeaders() throws Exception {
+        Exchange out = template.send("http://localhost:9090/test/filter", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setBody("Claus");
+                exchange.getIn().setHeader("bar", 123);
+            }
+        });
+
+        assertNotNull(out);
+        assertEquals("Hi Claus", out.getOut().getBody(String.class));
+
+        // there should be no internal Camel headers
+        // except for the response code
+        Map<String, Object> headers = out.getOut().getHeaders();
+        for (String key : headers.keySet()) {
+            if (!key.equalsIgnoreCase(Exchange.HTTP_RESPONSE_CODE)) {
+                assertTrue("Should not contain any Camel internal headers", !key.toLowerCase().startsWith("camel"));
+            } else {
+                assertEquals(200, headers.get(Exchange.HTTP_RESPONSE_CODE));
+            }
+        }
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry jndi = super.createRegistry();
+        jndi.bind("foo", new MyFooBean());
+        return jndi;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jetty:http://localhost:9090/test/filter").beanRef("foo");
+            }
+        };
+    }
+
+    public static class MyFooBean {
+
+        public String hello(String name) {
+            return "Hi " + name;
+        }
+    }
+}

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

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