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 2010/05/19 13:40:17 UTC
svn commit: r946133 - in
/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4:
CamelServlet.java DefaultHttpBinding.java HttpComponent.java
HttpEndpoint.java HttpProducer.java
Author: ningjiang
Date: Wed May 19 11:40:16 2010
New Revision: 946133
URL: http://svn.apache.org/viewvc?rev=946133&view=rev
Log:
CAMEL-2738 Merged the patch into camel-http4
Modified:
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
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/HttpEndpoint.java
camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java?rev=946133&r1=946132&r2=946133&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/CamelServlet.java Wed May 19 11:40:16 2010
@@ -53,6 +53,9 @@ public class CamelServlet extends HttpSe
if (((HttpEndpoint)consumer.getEndpoint()).isBridgeEndpoint()) {
exchange.setProperty(Exchange.SKIP_GZIP_ENCODING, Boolean.TRUE);
}
+ if (consumer.getEndpoint().isDisableStreamCache()) {
+ exchange.setProperty(Exchange.DISABLE_STREAM_CACHE, Boolean.TRUE);
+ }
exchange.setIn(new HttpMessage(exchange, request, response));
consumer.getProcessor().process(exchange);
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java?rev=946133&r1=946132&r2=946133&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java Wed May 19 11:40:16 2010
@@ -307,12 +307,20 @@ public class DefaultHttpBinding implemen
} else {
// otherwise use input stream and we need to cache it first
InputStream is = HttpConverter.toInputStream(request, httpMessage.getExchange());
- try {
- CachedOutputStream cos = new CachedOutputStream(httpMessage.getExchange());
- IOHelper.copy(is, cos);
- return cos.getStreamCache();
- } finally {
- is.close();
+ if (is == null) {
+ return is;
+ }
+ // convert the input stream to StreamCache if the stream cache is not disabled
+ if (httpMessage.getExchange().getProperty(Exchange.DISABLE_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
+ return is;
+ } else {
+ try {
+ CachedOutputStream cos = new CachedOutputStream(httpMessage.getExchange());
+ IOHelper.copy(is, cos);
+ return cos.getStreamCache();
+ } finally {
+ is.close();
+ }
}
}
}
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=946133&r1=946132&r2=946133&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 May 19 11:40:16 2010
@@ -143,6 +143,7 @@ public class HttpComponent extends Heade
Boolean throwExceptionOnFailure = getAndRemoveParameter(parameters, "throwExceptionOnFailure", Boolean.class);
Boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class);
Boolean matchOnUriPrefix = getAndRemoveParameter(parameters, "matchOnUriPrefix", Boolean.class);
+ Boolean disableStreamCache = getAndRemoveParameter(parameters, "disableStreamCache", Boolean.class);
// validate that we could resolve all httpClient. parameters as this component is lenient
validateParameters(uri, parameters, "httpClient.");
@@ -190,6 +191,9 @@ public class HttpComponent extends Heade
if (matchOnUriPrefix != null) {
endpoint.setMatchOnUriPrefix(matchOnUriPrefix);
}
+ if (disableStreamCache != null) {
+ endpoint.setDisableStreamCache(disableStreamCache);
+ }
setProperties(endpoint, parameters);
return endpoint;
Modified: camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java?rev=946133&r1=946132&r2=946133&view=diff
==============================================================================
--- camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java (original)
+++ camel/trunk/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java Wed May 19 11:40:16 2010
@@ -55,6 +55,7 @@ public class HttpEndpoint extends Defaul
private boolean bridgeEndpoint;
private boolean matchOnUriPrefix;
private boolean chunked = true;
+ private boolean disableStreamCache;
public HttpEndpoint() {
}
@@ -261,6 +262,14 @@ public class HttpEndpoint extends Defaul
public void setMatchOnUriPrefix(boolean match) {
this.matchOnUriPrefix = match;
}
+
+ public boolean isDisableStreamCache() {
+ return this.disableStreamCache;
+ }
+
+ public void setDisableStreamCache(boolean disable) {
+ this.disableStreamCache = disable;
+ }
public boolean isChunked() {
return this.chunked;
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=946133&r1=946132&r2=946133&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 May 19 11:40:16 2010
@@ -222,6 +222,8 @@ public class HttpProducer extends Defaul
}
private static InputStream doExtractResponseBody(InputStream is, Exchange exchange) throws IOException {
+ // As httpclient is using a AutoCloseInputStream, it will be closed when the connection is closed
+ // we need to cache the stream for it.
try {
CachedOutputStream cos = new CachedOutputStream(exchange);
IOHelper.copy(is, cos);