You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/05/12 09:47:00 UTC
svn commit: r1337466 - in /camel/branches/camel-2.9.x: ./
components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
Author: davsclaus
Date: Sat May 12 07:46:59 2012
New Revision: 1337466
URL: http://svn.apache.org/viewvc?rev=1337466&view=rev
Log:
CAMEL-5274: Fixed jetty http client issue with streams may be corrupt. Code aligned like http/http4 producers.
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1337464
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.9.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=1337466&r1=1337465&r2=1337466&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java (original)
+++ camel/branches/camel-2.9.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java Sat May 12 07:46:59 2012
@@ -117,10 +117,14 @@ public class JettyHttpProducer extends D
httpExchange.setRequestContent(new ByteArrayBuffer(bos.toByteArray()));
IOHelper.close(bos);
} else {
- // try with String at first
- String data = exchange.getIn().getBody(String.class);
- if (data != null) {
- String charset = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
+ Object body = exchange.getIn().getBody();
+ if (body instanceof String) {
+ String data = (String) body;
+ // be a bit careful with String as any type can most likely be converted to String
+ // so we only do an instanceof check and accept String if the body is really a String
+ // do not fallback to use the default charset as it can influence the request
+ // (for example application/x-www-form-urlencoded forms being sent)
+ String charset = IOHelper.getCharsetName(exchange, false);
if (charset != null) {
httpExchange.setRequestContent(new ByteArrayBuffer(data, charset));
} else {