camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject [1/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:54 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.15.x acd568bd8 -> d4791de1e
  refs/heads/master f741e04a8 -> dedb59d82


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

Branch: refs/heads/master
Commit: dedb59d82f9d60c4854cc22f6d16358e56995bab
Parents: f741e04
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:13 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/dedb59d8/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 0368e3e..6a45d3a 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
@@ -528,9 +528,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/dedb59d8/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/dedb59d8/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/dedb59d8/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 98d78c4..d3e0a4c 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
@@ -535,9 +535,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/dedb59d8/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/dedb59d8/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