camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [2/2] camel git commit: CAMEL-9086 - also add port info to host header as per rfc2616 sec14.23
Date Tue, 18 Aug 2015 18:49:55 GMT
CAMEL-9086 - also add port info to host header as per rfc2616 sec14.23


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

Branch: refs/heads/camel-2.15.x
Commit: d4791de1ed429ba826ee40f21dd717de1d83a7cb
Parents: acd568b
Author: Jonathan Anstey <janstey@gmail.com>
Authored: Tue Aug 18 16:19:13 2015 -0230
Committer: Jonathan Anstey <janstey@gmail.com>
Committed: Tue Aug 18 16:19:35 2015 -0230

----------------------------------------------------------------------
 .../camel/component/netty/http/DefaultNettyHttpBinding.java   | 7 ++++---
 .../NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java   | 3 ++-
 .../netty/http/NettyHttpBindingUseRelativePathInPostTest.java | 1 +
 .../camel/component/netty4/http/DefaultNettyHttpBinding.java  | 7 ++++---
 .../NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java   | 6 +++---
 .../http/NettyHttpBindingUseRelativePathInPostTest.java       | 1 +
 6 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/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 cb5b142..fbe40b1 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
@@ -531,9 +531,10 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable
{
         // must include HOST header as required by HTTP 1.1
         // use URI as its faster than URL (no DNS lookup)
         URI u = new URI(uri);
-        String host = u.getHost();
-        request.headers().set(HttpHeaders.Names.HOST, host);
-        LOG.trace("Host: {}", host);
+        String hostHeader = u.getHost() 
+                + (configuration.isUseRelativePath() ? ":" + u.getPort() : "");
+        request.headers().set(HttpHeaders.Names.HOST, hostHeader);
+        LOG.trace("Host: {}", hostHeader);
 
         // configure connection to accordingly to keep alive configuration
         // favor using the header from the message

http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
index 2939351..d7a9a57 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
@@ -56,7 +56,8 @@ public class NettyHttpBindingPreservePostFormUrlEncodedBodyTest extends
BaseNett
                         assertEquals("Get a wrong query parameter from the message header",
"b", exchange.getIn().getHeader("query2"));
                         assertEquals("Get a wrong form parameter from the message header",
"x", exchange.getIn().getHeader("b1"));
                         assertEquals("Get a wrong form parameter from the message header",
"y", exchange.getIn().getHeader("b2"));
-
+                        assertEquals("Get a wrong form parameter from the message header",
"localhost", exchange.getIn().getHeader("host"));
+                        
                         UpstreamMessageEvent event = (UpstreamMessageEvent) exchange.getIn().getHeader("CamelNettyMessageEvent");
                         DefaultHttpRequest request = (DefaultHttpRequest) event.getMessage();
                         assertNotEquals("Relative path should NOT be used in POST", "/myapp/myservice?query1=a&query2=b",
request.getUri());

http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingUseRelativePathInPostTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingUseRelativePathInPostTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingUseRelativePathInPostTest.java
index 3dcecd4..2519859 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingUseRelativePathInPostTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpBindingUseRelativePathInPostTest.java
@@ -56,6 +56,7 @@ public class NettyHttpBindingUseRelativePathInPostTest extends BaseNettyTest
{
                         assertEquals("Get a wrong query parameter from the message header",
"b", exchange.getIn().getHeader("query2"));
                         assertEquals("Get a wrong form parameter from the message header",
"x", exchange.getIn().getHeader("b1"));
                         assertEquals("Get a wrong form parameter from the message header",
"y", exchange.getIn().getHeader("b2"));
+                        assertEquals("Get a wrong form parameter from the message header",
"localhost:" + getPort(), exchange.getIn().getHeader("host"));
                         
                         UpstreamMessageEvent event = (UpstreamMessageEvent) exchange.getIn().getHeader("CamelNettyMessageEvent");
                         DefaultHttpRequest request = (DefaultHttpRequest) event.getMessage();

http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/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 0ff12cd..7fb4c3f 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
@@ -538,9 +538,10 @@ public class DefaultNettyHttpBinding implements NettyHttpBinding, Cloneable
{
         // must include HOST header as required by HTTP 1.1
         // use URI as its faster than URL (no DNS lookup)
         URI u = new URI(uri);
-        String host = u.getHost();
-        request.headers().set(HttpHeaders.Names.HOST, host);
-        LOG.trace("Host: {}", host);
+        String hostHeader = u.getHost() 
+                + (configuration.isUseRelativePath() ? ":" + u.getPort() : "");
+        request.headers().set(HttpHeaders.Names.HOST, hostHeader);
+        LOG.trace("Host: {}", hostHeader);
 
         // configure connection to accordingly to keep alive configuration
         // favor using the header from the message

http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
index 01c2627..861c227 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java
@@ -57,12 +57,12 @@ public class NettyHttpBindingPreservePostFormUrlEncodedBodyTest extends
BaseNett
                         assertEquals("Get a wrong query parameter from the message header",
"b", exchange.getIn().getHeader("query2"));
                         assertEquals("Get a wrong form parameter from the message header",
"x", exchange.getIn().getHeader("b1"));
                         assertEquals("Get a wrong form parameter from the message header",
"y", exchange.getIn().getHeader("b2"));
-
+                        assertEquals("Get a wrong form parameter from the message header",
"localhost", exchange.getIn().getHeader("host"));
+                        
                         NettyHttpMessage in = (NettyHttpMessage) exchange.getIn();      
                 
                         FullHttpRequest request = in.getHttpRequest();
                         assertNotEquals("Relative path should NOT be used in POST", "/myapp/myservice?query1=a&query2=b",
request.getUri());
-                                
-                        
+                                                  
                         // send a response
                         exchange.getOut().getHeaders().clear();
                         exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "text/plain");

http://git-wip-us.apache.org/repos/asf/camel/blob/d4791de1/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePathInPostTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePathInPostTest.java
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePathInPostTest.java
index 2fae960..39ed697 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePathInPostTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpBindingUseRelativePathInPostTest.java
@@ -56,6 +56,7 @@ public class NettyHttpBindingUseRelativePathInPostTest extends BaseNettyTest
{
                         assertEquals("Get a wrong query parameter from the message header",
"b", exchange.getIn().getHeader("query2"));
                         assertEquals("Get a wrong form parameter from the message header",
"x", exchange.getIn().getHeader("b1"));
                         assertEquals("Get a wrong form parameter from the message header",
"y", exchange.getIn().getHeader("b2"));
+                        assertEquals("Get a wrong form parameter from the message header",
"localhost:" + getPort(), exchange.getIn().getHeader("host"));
                         
                         NettyHttpMessage in = (NettyHttpMessage) exchange.getIn();      
                 
                         FullHttpRequest request = in.getHttpRequest();


Mime
View raw message