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 2015/09/11 16:18:47 UTC

[3/4] camel git commit: CAMEL-8734: Keep http path header with the original case.

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

Branch: refs/heads/camel-2.15.x
Commit: f91c643890e661548c6f91570a662a67b26898d3
Parents: 4c9865a
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Sep 11 16:14:56 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Sep 11 16:19:34 2015 +0200

----------------------------------------------------------------------
 .../netty4/http/DefaultNettyHttpBinding.java    |  5 ++-
 .../netty4/http/RestNettyHttpBinding.java       |  3 +-
 .../netty4/http/NettyMixedCaseHttpPathTest.java | 46 ++++++++++++++++++++
 .../http/NettyProxyMixedCasePathTest.java       |  1 +
 4 files changed, 51 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f91c6438/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettyHttpBinding.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettyHttpBinding.java
index 7fb4c3f..75ff204 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettyHttpBinding.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettyHttpBinding.java
@@ -137,12 +137,13 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable {
         String path = uri.getPath();
         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/f91c6438/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/RestNettyHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/RestNettyHttpBinding.java b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/RestNettyHttpBinding.java
index 597b6d5..ec9a493 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/RestNettyHttpBinding.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/RestNettyHttpBinding.java
@@ -24,9 +24,8 @@ import org.apache.camel.Exchange;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.spi.HeaderFilterStrategy;
 
-
 /**
- * A {@link org.apache.camel.component.netty.http.NettyHttpBinding} that supports the Rest DSL.
+ * A {@link org.apache.camel.component.netty4.http.NettyHttpBinding} that supports the Rest DSL.
  */
 public class RestNettyHttpBinding extends DefaultNettyHttpBinding {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f91c6438/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
new file mode 100644
index 0000000..6d17045
--- /dev/null
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyMixedCaseHttpPathTest.java
@@ -0,0 +1,46 @@
+/**
+ * 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.netty4.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("netty4-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("netty4-http:http://0.0.0.0:{{port}}/Shopping?matchOnUriPrefix=true")
+                    .to("mock:input")
+                    .transform(body().prepend("Bye "));
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/f91c6438/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
index f4cbfa7..e2935c1 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyProxyMixedCasePathTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.netty4.http;
 
+import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.junit.Test;