camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/4] camel git commit: CAMEL-8734: Keep http path header with the original case.
Date Fri, 11 Sep 2015 14:18:48 GMT
CAMEL-8734: Keep http path header with the original case.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1e2f7dc0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1e2f7dc0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1e2f7dc0

Branch: refs/heads/camel-2.15.x
Commit: 1e2f7dc0725100e9f436025c3845c1e9de2d1c01
Parents: f91c643
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Sep 11 16:16:57 2015 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 11 16:19:40 2015 +0200

----------------------------------------------------------------------
 .../netty/http/DefaultNettyHttpBinding.java     |  7 +--
 .../netty/http/NettyMixedCaseHttpPathTest.java  | 47 ++++++++++++++++++++
 2 files changed, 51 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1e2f7dc0/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
index fbe40b1..bd87ae5 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettyHttpBinding.java
@@ -133,14 +133,15 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable
{
 
         // strip the starting endpoint path so the path is relative to the endpoint uri
         String path = uri.getPath();
-        if (path != null) {
+        if (configuration.getPath() != null) {
             // need to match by lower case as we want to ignore case on context-path
-            path = path.toLowerCase(Locale.US);
+            String matchPath = path.toLowerCase(Locale.US);
             String match = configuration.getPath() != null ? configuration.getPath().toLowerCase(Locale.US)
: null;
-            if (match != null && path.startsWith(match)) {
+            if (match != null && matchPath.startsWith(match)) {
                 path = path.substring(configuration.getPath().length());
             }
         }
+        // keep the path uri using the case the request provided (do not convert to lower
case)
         headers.put(Exchange.HTTP_PATH, path);
 
         if (LOG.isTraceEnabled()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/1e2f7dc0/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyMixedCaseHttpPathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyMixedCaseHttpPathTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyMixedCaseHttpPathTest.java
new file mode 100644
index 0000000..0c0abe5
--- /dev/null
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyMixedCaseHttpPathTest.java
@@ -0,0 +1,47 @@
+/**
+ * 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.netty.http;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class NettyMixedCaseHttpPathTest extends BaseNettyTest {
+
+    @Test
+    public void testMixedCase() throws Exception {
+        getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_PATH, "/HelloWorld");
+
+        String out = template.requestBody("netty-http:http://0.0.0.0:{{port}}/SHoppING/HelloWorld",
"Camel", String.class);
+        assertEquals("Bye Camel", out);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("netty-http:http://0.0.0.0:{{port}}/Shopping?matchOnUriPrefix=true")
+                        .to("mock:input")
+                        .transform(body().prepend("Bye "));
+            }
+        };
+    }
+
+}


Mime
View raw message