Skip to content

Commit

Permalink
CAMEL-8821 Fixed the test errors in camel-http
Browse files Browse the repository at this point in the history
  • Loading branch information
WillemJiang committed May 31, 2015
1 parent 660ebaa commit 6ee8743
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Expand Up @@ -458,7 +458,7 @@ public Object parseBody(HttpMessage httpMessage) throws IOException {
}
}
// read the response body from servlet request
return HttpHelper.readResponseBodyFromServletRequest(request, httpMessage.getExchange());
return HttpHelper.readRequestBodyFromServletRequest(request, httpMessage.getExchange());
}
}

Expand Down
Expand Up @@ -160,14 +160,14 @@ public static Object deserializeJavaObjectFromStream(InputStream is, CamelContex
*
* @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.
*
Expand All @@ -176,7 +176,7 @@ public static Object readResponseBodyFromServletRequest(HttpServletRequest reque
* @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;
}
Expand All @@ -196,6 +196,29 @@ public static Object readResponseBodyFromInputStream(InputStream is, Exchange ex
}
}


/**
* 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.
*
Expand Down

0 comments on commit 6ee8743

Please sign in to comment.