camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-11765: camel-undertow - Consumer adds duplicate headers
Date Fri, 08 Sep 2017 13:36:58 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x 63c97d850 -> fd6fb1996


CAMEL-11765: camel-undertow - Consumer adds duplicate headers


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

Branch: refs/heads/camel-2.18.x
Commit: fd6fb1996b2af6649807d8acdfe970de94a1187d
Parents: 63c97d8
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Sep 8 15:36:38 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Sep 8 15:36:38 2017 +0200

----------------------------------------------------------------------
 .../undertow/DefaultUndertowHttpBinding.java    | 21 ++++++++++----------
 .../rest/RestUndertowProducerGetTest.java       |  3 +++
 2 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fd6fb199/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
index 77e612c..3e1b9a8 100644
--- a/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
+++ b/components/camel-undertow/src/main/java/org/apache/camel/component/undertow/DefaultUndertowHttpBinding.java
@@ -121,15 +121,6 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding
{
     public void populateCamelHeaders(HttpServerExchange httpExchange, Map<String, Object>
headersMap, Exchange exchange) throws Exception {
         LOG.trace("populateCamelHeaders: {}");
 
-        // NOTE: these headers is applied using the same logic as camel-http/camel-jetty
to be consistent
-        headersMap.put(Exchange.HTTP_METHOD, httpExchange.getRequestMethod().toString());
-        // strip query parameters from the uri
-        headersMap.put(Exchange.HTTP_URL, httpExchange.getRequestURL());
-        // uri is without the host and port
-        headersMap.put(Exchange.HTTP_URI, httpExchange.getRequestURI());
-        headersMap.put(Exchange.HTTP_QUERY, httpExchange.getQueryString());
-        headersMap.put(Exchange.HTTP_RAW_QUERY, httpExchange.getQueryString());
-
         String path = httpExchange.getRequestPath();
         UndertowEndpoint endpoint = (UndertowEndpoint) exchange.getFromEndpoint();
         if (endpoint.getHttpURI() != null) {
@@ -137,7 +128,7 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding
{
             String endpointPath = endpoint.getHttpURI().getPath();
             String matchPath = path.toLowerCase(Locale.US);
             String match = endpointPath.toLowerCase(Locale.US);
-            if (match != null && matchPath.startsWith(match)) {
+            if (matchPath.startsWith(match)) {
                 path = path.substring(endpointPath.length());
             }
         }
@@ -209,6 +200,15 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding
{
                 headersMap.put(paramName, predicateContextParams.get(paramName));
             }
         }
+
+        // NOTE: these headers is applied using the same logic as camel-http/camel-jetty
to be consistent
+        headersMap.put(Exchange.HTTP_METHOD, httpExchange.getRequestMethod().toString());
+        // strip query parameters from the uri
+        headersMap.put(Exchange.HTTP_URL, httpExchange.getRequestURL());
+        // uri is without the host and port
+        headersMap.put(Exchange.HTTP_URI, httpExchange.getRequestURI());
+        headersMap.put(Exchange.HTTP_QUERY, httpExchange.getQueryString());
+        headersMap.put(Exchange.HTTP_RAW_QUERY, httpExchange.getQueryString());
     }
 
     @Override
@@ -246,6 +246,7 @@ public class DefaultUndertowHttpBinding implements UndertowHttpBinding
{
                 }
             }
         }
+
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/fd6fb199/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerGetTest.java
----------------------------------------------------------------------
diff --git a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerGetTest.java
b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerGetTest.java
index 28fe767..388326e 100644
--- a/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerGetTest.java
+++ b/components/camel-undertow/src/test/java/org/apache/camel/component/undertow/rest/RestUndertowProducerGetTest.java
@@ -48,6 +48,9 @@ public class RestUndertowProducerGetTest extends BaseUndertowTest {
                         .to("mock:input")
                         .process(new Processor() {
                             public void process(Exchange exchange) throws Exception {
+                                String method = exchange.getIn().getHeader(Exchange.HTTP_METHOD,
String.class);
+                                assertEquals("GET", method);
+
                                 String id = exchange.getIn().getHeader("id", String.class);
                                 exchange.getOut().setBody(id + ";Donald Duck");
                             }


Mime
View raw message