Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x 4c9865a39 -> 1e2f7dc07
  refs/heads/master b5d44c1af -> 64971720d


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/64971720
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/64971720
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/64971720

Branch: refs/heads/master
Commit: 64971720dc41aef56f61004b8f6fbda29ed197ab
Parents: 1abbae9
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Sep 11 16:16:57 2015 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Sep 11 16:19:08 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/64971720/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 6a45d3a..8146433 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/64971720/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 "));
+            }
+        };
+    }
+
+}

Reply via email to