You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2012/11/01 13:29:11 UTC
svn commit: r1404558 - in /camel/branches/camel-2.10.x: ./
components/camel-ahc/src/main/java/org/apache/camel/component/ahc/
components/camel-http/src/main/java/org/apache/camel/component/http/
components/camel-http4/src/main/java/org/apache/camel/com...
Author: ningjiang
Date: Thu Nov 1 12:29:10 2012
New Revision: 1404558
URL: http://svn.apache.org/viewvc?rev=1404558&view=rev
Log:
CAMEL-5757 fix the host setting issue on the camel-http producer when the bridgeEndpoint option is true
Merged revisions 1404508,1404510 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1404508 | ningjiang | 2012-11-01 17:04:37 +0800 (Thu, 01 Nov 2012) | 1 line
CAMEL-5757 fix the host setting issue on the camel-http producer when the bridgeEndpoint option is true
........
r1404510 | ningjiang | 2012-11-01 17:05:26 +0800 (Thu, 01 Nov 2012) | 1 line
CAMEL-5757 updated the code of camel-ahc
........
Modified:
camel/branches/camel-2.10.x/ (props changed)
camel/branches/camel-2.10.x/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
camel/branches/camel-2.10.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1404508-1404510
Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.10.x/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java (original)
+++ camel/branches/camel-2.10.x/components/camel-ahc/src/main/java/org/apache/camel/component/ahc/DefaultAhcBinding.java Thu Nov 1 12:29:10 2012
@@ -55,6 +55,8 @@ public class DefaultAhcBinding implement
public Request prepareRequest(AhcEndpoint endpoint, Exchange exchange) throws CamelExchangeException {
if (endpoint.isBridgeEndpoint()) {
exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
+ // Need to remove the Host key as it should be not used
+ exchange.getIn().getHeaders().remove("host");
}
RequestBuilder builder = new RequestBuilder();
Modified: camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java (original)
+++ camel/branches/camel-2.10.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpProducer.java Thu Nov 1 12:29:10 2012
@@ -85,6 +85,8 @@ public class HttpProducer extends Defaul
if (queryString != null) {
skipRequestHeaders = URISupport.parseQuery(queryString);
}
+ // Need to remove the Host key as it should be not used
+ exchange.getIn().getHeaders().remove("host");
}
HttpMethod method = createMethod(exchange);
Message in = exchange.getIn();
Modified: camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java (original)
+++ camel/branches/camel-2.10.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java Thu Nov 1 12:29:10 2012
@@ -90,6 +90,8 @@ public class HttpProducer extends Defaul
if (queryString != null) {
skipRequestHeaders = URISupport.parseQuery(queryString);
}
+ // Need to remove the Host key as it should be not used
+ exchange.getIn().getHeaders().remove("host");
}
HttpRequestBase httpRequest = createMethod(exchange);
Message in = exchange.getIn();
Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java Thu Nov 1 12:29:10 2012
@@ -147,6 +147,8 @@ public class JettyHttpProducer extends D
if (queryString != null) {
skipRequestHeaders = URISupport.parseQuery(queryString);
}
+ // Need to remove the Host key as it should be not used
+ exchange.getIn().getHeaders().remove("host");
}
// propagate headers as HTTP headers
Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/BaseJettyTest.java Thu Nov 1 12:29:10 2012
@@ -29,6 +29,8 @@ import org.junit.BeforeClass;
public abstract class BaseJettyTest extends CamelTestSupport {
private static volatile int port;
+
+ private static volatile int port2;
private final AtomicInteger counter = new AtomicInteger(1);
@@ -36,6 +38,8 @@ public abstract class BaseJettyTest exte
public static void initPort() throws Exception {
// start from somewhere in the 23xxx range
port = AvailablePortFinder.getNextAvailable(23000);
+ // find another ports for proxy route test
+ port2 = AvailablePortFinder.getNextAvailable(24000);
}
@Override
@@ -51,8 +55,8 @@ public abstract class BaseJettyTest exte
Properties prop = new Properties();
prop.setProperty("port", "" + getPort());
+ prop.setProperty("port2", "" + getPort2());
jndi.bind("prop", prop);
-
return jndi;
}
@@ -67,5 +71,10 @@ public abstract class BaseJettyTest exte
protected int getPort() {
return port;
}
+
+ protected static int getPort2() {
+ return port2;
+ }
+
}
Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProxyRouteTest.java Thu Nov 1 12:29:10 2012
@@ -47,6 +47,12 @@ public class HttpProxyRouteTest extends
out = template.requestBody("http://localhost:{{port}}/proxy/path", null, String.class);
assertEquals("/otherEndpoint/path", out);
}
+
+ @Test
+ public void testHttpProxyHostHeader() throws Exception {
+ String out = template.requestBody("http://localhost:{{port}}/proxyServer", null, String.class);
+ assertEquals("Get a wrong host header", "localhost:" + getPort2(), out);
+ }
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@@ -60,6 +66,11 @@ public class HttpProxyRouteTest extends
from("jetty://http://localhost:{{port}}/bye").transform(header("foo").prepend("Bye "));
from("jetty://http://localhost:{{port}}/otherEndpoint?matchOnUriPrefix=true").transform(header(Exchange.HTTP_PATH));
+
+ from("jetty://http://localhost:{{port}}/proxyServer")
+ .to("http://localhost:{{port2}}/host?bridgeEndpoint=true");
+
+ from("jetty://http://localhost:{{port2}}/host").transform(header("host"));
}
};
}
Modified: camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java?rev=1404558&r1=1404557&r2=1404558&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java (original)
+++ camel/branches/camel-2.10.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyRouteTest.java Thu Nov 1 12:29:10 2012
@@ -35,6 +35,12 @@ public class JettyRouteTest extends Base
String body = context.getTypeConverter().convertTo(String.class, response);
assertEquals("<html><body>Book 123 is Camel in Action</body></html>", body);
}
+
+ @Test
+ public void testHttpProxyHostHeader() throws Exception {
+ String out = template.requestBody("http://localhost:{{port}}/proxyServer", null, String.class);
+ assertEquals("Get a wrong host header", "localhost:" + getPort2(), out);
+ }
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
@@ -43,6 +49,11 @@ public class JettyRouteTest extends Base
// START SNIPPET: e1
from("jetty:http://localhost:{{port}}/myapp/myservice").process(new MyBookService());
// END SNIPPET: e1
+
+ from("jetty://http://localhost:{{port}}/proxyServer")
+ .to("http://localhost:{{port2}}/host?bridgeEndpoint=true");
+
+ from("jetty://http://localhost:{{port2}}/host").transform(header("host"));
}
};
}