camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: CAMEL-9384 Host HTTP header should contain a port number
Date Sat, 05 Dec 2015 08:51:15 GMT
CAMEL-9384 Host HTTP header should contain a port number


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

Branch: refs/heads/camel-2.16.x
Commit: 958b66b603dbbc532c63cf886aec157c57826750
Parents: 85bbbb2
Author: Tomas Rohovsky <trohovsk@redhat.com>
Authored: Tue Dec 1 19:38:10 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Dec 5 09:50:12 2015 +0100

----------------------------------------------------------------------
 .../camel/component/netty/http/DefaultNettyHttpBinding.java  | 3 +--
 .../NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java  | 6 +++---
 .../http/NettyHttpBindingUseRelativePathInPostTest.java      | 4 ++--
 .../camel/component/netty/http/NettyHttpHeadersTest.java     | 2 +-
 .../camel/component/netty4/http/DefaultNettyHttpBinding.java | 3 +--
 .../NettyHttpBindingPreservePostFormUrlEncodedBodyTest.java  | 8 ++++----
 .../http/NettyHttpBindingUseRelativePathInPostTest.java      | 6 +++---
 .../camel/component/netty4/http/NettyHttpHeadersTest.java    | 2 +-
 8 files changed, 16 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/958b66b6/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 8146433..05bd551 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
@@ -529,8 +529,7 @@ 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 hostHeader = u.getHost() 
-                + (configuration.isUseRelativePath() ? ":" + u.getPort() : "");
+        String hostHeader = u.getHost() + (u.getPort() == 80 ? "" : ":" + u.getPort());
         request.headers().set(HttpHeaders.Names.HOST, hostHeader);
         LOG.trace("Host: {}", hostHeader);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/958b66b6/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 d7a9a57..62e2174 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,12 +56,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"));
-                        
+                        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();
                         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/958b66b6/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 2519859..9925add 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
@@ -57,11 +57,11 @@ public class NettyHttpBindingUseRelativePathInPostTest extends BaseNettyTest
{
                         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();
                         assertEquals("Relative path not 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/958b66b6/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeadersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeadersTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeadersTest.java
index 27671b5..2a53d1f 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeadersTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpHeadersTest.java
@@ -26,7 +26,7 @@ public class NettyHttpHeadersTest extends BaseNettyTest {
     public void testHttpHeaders() throws Exception {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived("beer", "yes");
-        getMockEndpoint("mock:input").expectedHeaderReceived("host", "localhost");
+        getMockEndpoint("mock:input").expectedHeaderReceived("host", "localhost:" + getPort());
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://localhost:"
+ getPort() + "/foo");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URI, "/foo");

http://git-wip-us.apache.org/repos/asf/camel/blob/958b66b6/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 7a8d7c4..0a183a3 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
@@ -536,8 +536,7 @@ 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 hostHeader = u.getHost() 
-                + (configuration.isUseRelativePath() ? ":" + u.getPort() : "");
+        String hostHeader = u.getHost() + (u.getPort() == 80 ? "" : ":" + u.getPort());
         request.headers().set(HttpHeaders.Names.HOST, hostHeader);
         LOG.trace("Host: {}", hostHeader);
 

http://git-wip-us.apache.org/repos/asf/camel/blob/958b66b6/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 868574c..6057f4f 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
@@ -58,12 +58,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();      
                 
+                        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();
                         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/958b66b6/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 e8a6da2..b387602 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
@@ -58,11 +58,11 @@ public class NettyHttpBindingUseRelativePathInPostTest extends BaseNettyTest
{
                         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();      
                 
+
+                        NettyHttpMessage in = (NettyHttpMessage) exchange.getIn();
                         FullHttpRequest request = in.getHttpRequest();
                         assertEquals("Relative path not 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/958b66b6/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeadersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeadersTest.java
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeadersTest.java
index 340ecff..65021b0 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeadersTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/NettyHttpHeadersTest.java
@@ -26,7 +26,7 @@ public class NettyHttpHeadersTest extends BaseNettyTest {
     public void testHttpHeaders() throws Exception {
         getMockEndpoint("mock:input").expectedBodiesReceived("Hello World");
         getMockEndpoint("mock:input").expectedHeaderReceived("beer", "yes");
-        getMockEndpoint("mock:input").expectedHeaderReceived("host", "localhost");
+        getMockEndpoint("mock:input").expectedHeaderReceived("host", "localhost:" + getPort());
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_METHOD, "POST");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URL, "http://localhost:"
+ getPort() + "/foo");
         getMockEndpoint("mock:input").expectedHeaderReceived(Exchange.HTTP_URI, "/foo");


Mime
View raw message