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 2015/05/31 11:07:36 UTC
[1/3] camel git commit: CAMEL-8774 Remove the System.out.println
Repository: camel
Updated Branches:
refs/heads/master c5254616b -> 0b4a1675d
CAMEL-8774 Remove the System.out.println
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/660ebaaf
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/660ebaaf
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/660ebaaf
Branch: refs/heads/master
Commit: 660ebaaf95efaf1b21b9a36616739be5c1e7cc98
Parents: c525461
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun May 31 16:58:01 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun May 31 16:58:01 2015 +0800
----------------------------------------------------------------------
.../org/apache/camel/component/http4/HttpProducer.java | 13 ++++++-------
.../camel/component/http4/HttpCompressionTest.java | 13 ++++++-------
2 files changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/660ebaaf/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
index a301f54..612c6ce 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpProducer.java
@@ -67,7 +67,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * @version
+ * @version
*/
public class HttpProducer extends DefaultProducer {
private static final Logger LOG = LoggerFactory.getLogger(HttpProducer.class);
@@ -102,7 +102,7 @@ public class HttpProducer extends DefaultProducer {
if (queryString != null) {
skipRequestHeaders = URISupport.parseQuery(queryString, false, true);
}
- // Need to remove the Host key as it should be not used
+ // Need to remove the Host key as it should be not used
exchange.getIn().getHeaders().remove("host");
}
HttpRequestBase httpRequest = createMethod(exchange);
@@ -194,7 +194,6 @@ public class HttpProducer extends DefaultProducer {
// propagate HTTP response headers
Header[] headers = httpResponse.getAllHeaders();
for (Header header : headers) {
- System.out.println("headers name " + header.getName());
String name = header.getName();
String value = header.getValue();
if (name.toLowerCase().equals("content-type")) {
@@ -210,7 +209,7 @@ public class HttpProducer extends DefaultProducer {
// preserve headers from in by copying any non existing headers
// to avoid overriding existing headers with old values
- // Just filter the http protocol headers
+ // Just filter the http protocol headers
MessageHelper.copyHeaders(exchange.getIn(), answer, httpProtocolHeaderFilterStrategy, false);
}
@@ -411,19 +410,19 @@ public class HttpProducer extends DefaultProducer {
if (data != null) {
String contentTypeString = ExchangeHelper.getContentType(exchange);
ContentType contentType = null;
-
+
//Check the contentType is valid or not, If not it throws an exception.
//When ContentType.parse parse method parse "multipart/form-data;boundary=---------------------------j2radvtrk",
//it removes "boundary" from Content-Type; I have to use contentType.create method.
if (contentTypeString != null) {
- // using ContentType.parser for charset
+ // using ContentType.parser for charset
if (contentTypeString.indexOf("charset") > 0) {
contentType = ContentType.parse(contentTypeString);
} else {
contentType = ContentType.create(contentTypeString);
}
}
-
+
if (contentTypeString != null && HttpConstants.CONTENT_TYPE_JAVA_SERIALIZED_OBJECT.equals(contentTypeString)) {
// serialized java object
Serializable obj = in.getMandatoryBody(Serializable.class);
http://git-wip-us.apache.org/repos/asf/camel/blob/660ebaaf/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCompressionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCompressionTest.java b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCompressionTest.java
index e6d3d9e..e9aba3e 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCompressionTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpCompressionTest.java
@@ -50,8 +50,8 @@ import org.apache.http.util.EntityUtils;
import org.junit.Test;
/**
- *
- * @version
+ *
+ * @version
*/
public class HttpCompressionTest extends BaseHttpTest {
@@ -71,9 +71,8 @@ public class HttpCompressionTest extends BaseHttpTest {
assertNotNull(out);
Map<String, Object> headers = out.getHeaders();
- System.out.println(headers);
assertEquals(HttpStatus.SC_OK, headers.get(Exchange.HTTP_RESPONSE_CODE));
-
+
assertBody(out.getBody(String.class));
}
@@ -132,7 +131,7 @@ public class HttpCompressionTest extends BaseHttpTest {
public long getContentLength() {
return -1;
}
-
+
@Override
public boolean isStreaming() {
return false;
@@ -170,11 +169,11 @@ public class HttpCompressionTest extends BaseHttpTest {
public long getContentLength() {
return -1;
}
-
+
@Override
public boolean isStreaming() {
return false;
}
}
}
-}
\ No newline at end of file
+}
[3/3] camel git commit: CAMEL-8821 Fixed the test errors in
camel-http4
Posted by ni...@apache.org.
CAMEL-8821 Fixed the test errors in camel-http4
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0b4a1675
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0b4a1675
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0b4a1675
Branch: refs/heads/master
Commit: 0b4a1675dacd278f0ccd342f1dc4c696dd281c11
Parents: 6ee8743
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun May 31 17:05:53 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun May 31 17:05:53 2015 +0800
----------------------------------------------------------------------
.../component/http4/DefaultHttpBinding.java | 2 +-
.../component/http4/helper/HttpHelper.java | 43 +++++++++++++++-----
2 files changed, 33 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0b4a1675/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
index c7a9e2c..233c09f 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/DefaultHttpBinding.java
@@ -421,7 +421,7 @@ public class DefaultHttpBinding implements HttpBinding {
}
}
// read the response body from servlet request
- return HttpHelper.readResponseBodyFromServletRequest(request, httpMessage.getExchange());
+ return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0b4a1675/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
index 4201ed9..d1996bc 100644
--- a/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
+++ b/components/camel-http4/src/main/java/org/apache/camel/component/http4/helper/HttpHelper.java
@@ -140,27 +140,27 @@ public final class HttpHelper {
}
/**
- * Reads the response body from the given http servlet request.
+ * Reads the request body from the given http servlet request.
*
* @param request http servlet request
* @param exchange the exchange
- * @return the response body, can be <tt>null</tt> if no body
- * @throws IOException is thrown if error reading response body
+ * @return the request body, can be <tt>null</tt> if no body
+ * @throws IOException is thrown if error reading request body
*/
- public static Object readResponseBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
+ public static Object readRequestBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
InputStream is = HttpConverter.toInputStream(request, exchange);
- return readResponseBodyFromInputStream(is, exchange);
+ return readRequestBodyFromInputStream(is, exchange);
}
-
+
/**
- * Reads the response body from the given input stream.
+ * Reads the request body from the given input stream.
*
* @param is the input stream
* @param exchange the exchange
- * @return the response body, can be <tt>null</tt> if no body
- * @throws IOException is thrown if error reading response body
+ * @return the request body, can be <tt>null</tt> if no body
+ * @throws IOException is thrown if error reading request body
*/
- public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+ public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
if (is == null) {
return null;
}
@@ -171,9 +171,30 @@ public final class HttpHelper {
DefaultCamelContext context = (DefaultCamelContext) exchange.getContext();
disableStreamCaching = !context.isStreamCaching();
}
+ if (disableStreamCaching) {
+ return is;
+ } else {
+ CachedOutputStream cos = new CachedOutputStream(exchange);
+ IOHelper.copyAndCloseInput(is, cos);
+ return cos.newStreamCache();
+ }
+ }
+
+ /**
+ * Reads the response body from the given input stream.
+ *
+ * @param is the input stream
+ * @param exchange the exchange
+ * @return the response body, can be <tt>null</tt> if no body
+ * @throws IOException is thrown if error reading response body
+ */
+ public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+ if (is == null) {
+ return null;
+ }
// convert the input stream to StreamCache if the stream cache is not disabled
- if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, disableStreamCaching, Boolean.class)) {
+ if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
return is;
} else {
CachedOutputStream cos = new CachedOutputStream(exchange);
[2/3] camel git commit: CAMEL-8821 Fixed the test errors in camel-http
Posted by ni...@apache.org.
CAMEL-8821 Fixed the test errors in camel-http
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6ee8743f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6ee8743f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6ee8743f
Branch: refs/heads/master
Commit: 6ee8743fae9fe4cd64e37b2511872045fa1f74c1
Parents: 660ebaa
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun May 31 17:05:31 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun May 31 17:05:31 2015 +0800
----------------------------------------------------------------------
.../component/http/DefaultHttpBinding.java | 2 +-
.../camel/component/http/helper/HttpHelper.java | 31 +++++++++++++++++---
2 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/6ee8743f/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
index 97c81c0..3adcd02 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/DefaultHttpBinding.java
@@ -458,7 +458,7 @@ public class DefaultHttpBinding implements HttpBinding {
}
}
// read the response body from servlet request
- return HttpHelper.readResponseBodyFromServletRequest(request, httpMessage.getExchange());
+ return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/6ee8743f/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
----------------------------------------------------------------------
diff --git a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
index edee4b4..e5bbf45 100644
--- a/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
+++ b/components/camel-http/src/main/java/org/apache/camel/component/http/helper/HttpHelper.java
@@ -160,14 +160,14 @@ public final class HttpHelper {
*
* @param request http servlet request
* @param exchange the exchange
- * @return the response body, can be <tt>null</tt> if no body
+ * @return the request body, can be <tt>null</tt> if no body
* @throws IOException is thrown if error reading response body
*/
- public static Object readResponseBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
+ public static Object readRequestBodyFromServletRequest(HttpServletRequest request, Exchange exchange) throws IOException {
InputStream is = HttpConverter.toInputStream(request, exchange);
return readResponseBodyFromInputStream(is, exchange);
}
-
+
/**
* Reads the response body from the given input stream.
*
@@ -176,7 +176,7 @@ public final class HttpHelper {
* @return the response body, can be <tt>null</tt> if no body
* @throws IOException is thrown if error reading response body
*/
- public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+ public static Object readRequestBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
if (is == null) {
return null;
}
@@ -196,6 +196,29 @@ public final class HttpHelper {
}
}
+
+ /**
+ * Reads the response body from the given input stream.
+ *
+ * @param is the input stream
+ * @param exchange the exchange
+ * @return the response body, can be <tt>null</tt> if no body
+ * @throws IOException is thrown if error reading response body
+ */
+ public static Object readResponseBodyFromInputStream(InputStream is, Exchange exchange) throws IOException {
+ if (is == null) {
+ return null;
+ }
+ // convert the input stream to StreamCache if the stream cache is not disabled
+ if (exchange.getProperty(Exchange.DISABLE_HTTP_STREAM_CACHE, Boolean.FALSE, Boolean.class)) {
+ return is;
+ } else {
+ CachedOutputStream cos = new CachedOutputStream(exchange);
+ IOHelper.copyAndCloseInput(is, cos);
+ return cos.newStreamCache();
+ }
+ }
+
/**
* Creates the URL to invoke.
*