* @param method the method that was executed
* @return the response as a stream
* @throws IOException can be thrown
*/
protected static InputStream extractResponseBody(HttpMethod method) throws IOException {
LoadingByteArrayOutputStream bos = null;
InputStream is = null;
try {
bos = new LoadingByteArrayOutputStream();
is = method.getResponseBodyAsStream();
// in case of no response stream
if (is == null) {
return null;
}
IOUtils.copy(is, bos);
bos.flush();
return bos.createInputStream();
} finally {
ObjectHelper.close(is, "Extracting response body", LOG);
ObjectHelper.close(bos, "Extracting response body", LOG);
}
}