Author: davsclaus
Date: Sat May 12 07:45:41 2012
New Revision: 1337464
URL: http://svn.apache.org/viewvc?rev=1337464&view=rev
Log:
CAMEL-5274: Fixed jetty http client issue with streams may be corrupt. Code
aligned like http/http4 producers.
Modified:
camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
Modified:
camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java?rev=1337464&r1=1337463&r2=1337464&view=diff
==============================================================================
---
camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
(original)
+++
camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
Sat May 12 07:45:41 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 {