Author: ningjiang
Date: Wed Sep 28 08:58:44 2011
New Revision: 1176787
URL: http://svn.apache.org/viewvc?rev=1176787&view=rev
Log:
Merged revisions 1176781-1176782 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r1176781 | ningjiang | 2011-09-28 16:23:35 +0800 (Wed, 28 Sep 2011) | 1 line
CAMEL-4497 HttpPollingConsumer Get URL should support the property place
holders as HttpProducer does
........
r1176782 | ningjiang | 2011-09-28 16:27:15 +0800 (Wed, 28 Sep 2011) | 1 line
CAMEL-4489, CAMEL-4497 fixed the camel-http4 proxy url issue
........
Modified:
camel/branches/camel-2.8.x/ (props changed)
camel/branches/camel-2.8.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
camel/branches/camel-2.8.x/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Sep 28 08:58:44 2011
@@ -1 +1 @@
-/camel/trunk:1173732,1173958,1174047,1174129,1174245,1174565,1174626,1174745,1174817,1174837,1175139,1175313,1175321,1175437-1175438,1176274
+/camel/trunk:1173732,1173958,1174047,1174129,1174245,1174565,1174626,1174745,1174817,1174837,1175139,1175313,1175321,1175437-1175438,1176274,1176781-1176782
Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
camel/branches/camel-2.8.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java?rev=1176787&r1=1176786&r2=1176787&view=diff
==============================================================================
---
camel/branches/camel-2.8.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
(original)
+++
camel/branches/camel-2.8.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpPollingConsumer.java
Wed Sep 28 08:58:44 2011
@@ -58,7 +58,7 @@ public class HttpPollingConsumer extends
protected Exchange doReceive(int timeout) {
Exchange exchange = endpoint.createExchange();
- HttpMethod method = createMethod();
+ HttpMethod method = createMethod(exchange);
// set optional timeout in millis
if (timeout > 0) {
@@ -111,8 +111,8 @@ public class HttpPollingConsumer extends
// Implementation methods
//-------------------------------------------------------------------------
- protected HttpMethod createMethod() {
- String uri = endpoint.getEndpointUri();
+ protected HttpMethod createMethod(Exchange exchange) {
+ String uri = HttpHelper.createURL(exchange, endpoint);
return new GetMethod(uri);
}
Modified:
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java?rev=1176787&r1=1176786&r2=1176787&view=diff
==============================================================================
---
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
(original)
+++
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
Wed Sep 28 08:58:44 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/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java?rev=1176787&r1=1176786&r2=1176787&view=diff
==============================================================================
---
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
(original)
+++
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpPollingConsumer.java
Wed Sep 28 08:58:44 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/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java?rev=1176787&r1=1176786&r2=1176787&view=diff
==============================================================================
---
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
(original)
+++
camel/branches/camel-2.8.x/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
Wed Sep 28 08:58:44 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/branches/camel-2.8.x/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
URL:
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java?rev=1176787&r1=1176786&r2=1176787&view=diff
==============================================================================
---
camel/branches/camel-2.8.x/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
(original)
+++
camel/branches/camel-2.8.x/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpProxyServerTest.java
Wed Sep 28 08:58:44 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();