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 2011/09/28 10:27:16 UTC
svn commit: r1176782 - in /camel/trunk/components/camel-http4/src:
main/java/org/apache/camel/component/http4/
test/java/org/apache/camel/component/http4/
Author: ningjiang
Date: Wed Sep 28 08:27:15 2011
New Revision: 1176782
URL: http://svn.apache.org/viewvc?rev=1176782&view=rev
Log:
CAMEL-4489, CAMEL-4497 fixed the camel-http4 proxy url issue
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1176782&r1=1176781&r2=1176782&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java Wed Sep 28 08:27:15 2011
@@ -194,7 +194,15 @@ public class HttpComponent extends Heade
HttpClientConfigurer configurer = createHttpClientConfigurer(parameters, secure);
URI endpointUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(httpClientParameters));
// restructure uri to be based on the parameters left as we dont want to include the Camel internal options
- URI httpUri = URISupport.createRemainingURI(new URI(addressUri), CastUtils.cast(parameters));
+ // The httpUri should be start with http or https
+ String httpUriAddress = addressUri;
+ if (addressUri.startsWith("http4")) {
+ httpUriAddress = "http" + addressUri.substring(5);
+ }
+ if (addressUri.startsWith("https4")) {
+ httpUriAddress = "https" + addressUri.substring(6);
+ }
+ URI httpUri = URISupport.createRemainingURI(new URI(httpUriAddress), CastUtils.cast(parameters));
// validate http uri that end-user did not duplicate the http part that can be a common error
String part = httpUri.getSchemeSpecificPart();
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java?rev=1176782&r1=1176781&r2=1176782&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java Wed Sep 28 08:27:15 2011
@@ -62,7 +62,7 @@ public class HttpPollingConsumer extends
protected Exchange doReceive(int timeout) {
Exchange exchange = endpoint.createExchange();
- HttpRequestBase method = createMethod();
+ HttpRequestBase method = createMethod(exchange);
// set optional timeout in millis
if (timeout > 0) {
@@ -125,8 +125,8 @@ public class HttpPollingConsumer extends
// Implementation methods
//-------------------------------------------------------------------------
- protected HttpRequestBase createMethod() {
- String uri = endpoint.getEndpointUri();
+ protected HttpRequestBase createMethod(Exchange exchange) {
+ String uri = HttpHelper.createURL(exchange, endpoint);
return new HttpGet(uri);
}
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1176782&r1=1176781&r2=1176782&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java Wed Sep 28 08:27:15 2011
@@ -338,13 +338,7 @@ public class HttpProducer extends Defaul
+ ". If you are forwarding/bridging http endpoints, then enable the bridgeEndpoint option on the endpoint: " + getEndpoint());
}
- // Changed the schema to http4 to normal http by default
- String schema = "http";
- if (uri.getScheme().equals("https4")) {
- schema = "https";
- }
-
- StringBuilder builder = new StringBuilder(schema).append("://").append(uri.getHost());
+ StringBuilder builder = new StringBuilder(uri.getScheme()).append("://").append(uri.getHost());
if (uri.getPort() != -1) {
builder.append(":").append(uri.getPort());
Modified: camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java?rev=1176782&r1=1176781&r2=1176782&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java (original)
+++ camel/trunk/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java Wed Sep 28 08:27:15 2011
@@ -182,6 +182,15 @@ public class HttpProxyServerTest extends
assertExchange(exchange);
}
+
+ public void httpGetPullEndpointWithProxyAndWithUser() {
+ proxy.register("*", new ProxyAuthenticationValidationHandler("GET", null, null, getExpectedContent(), user, password));
+
+ Exchange exchange = consumer.receive("http4://" + getHostName() + ":" + getPort() + "?proxyAuthHost="
+ + getProxyHost() + "&proxyAuthPort=" + getProxyPort() + "&proxyAuthUsername=camel&proxyAuthPassword=password");
+
+ assertExchange(exchange);
+ }
private String getProxyHost() {
return proxy.getServiceAddress().getHostName();
@@ -194,7 +203,12 @@ public class HttpProxyServerTest extends
class RequestProxyBasicAuth implements HttpRequestInterceptor {
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
String auth = null;
-
+
+ String requestLine = request.getRequestLine().toString();
+ // assert we set a write GET URI
+ if (requestLine.contains("http4://localhost")) {
+ throw new HttpException("Get a wrong proxy GET url");
+ }
Header h = request.getFirstHeader(AUTH.PROXY_AUTH_RESP);
if (h != null) {
String s = h.getValue();