originalURI.getPort(),
originalURI.getRawPath(),
URLEncodedUtils.format(newQuery, "UTF-8"), null);
} catch (URISyntaxException e) {
e.printStackTrace();
throw new RiakIORuntimeException(e);
}
httpMethod.setURI(newURI);
}
}
HttpEntity entity = null;
try {
org.apache.http.HttpResponse response = httpClient.execute(httpMethod);
int status = 0;
if (response.getStatusLine() != null) {
status = response.getStatusLine().getStatusCode();
}
Map<String, String> headers = ClientUtils.asHeaderMap(response.getAllHeaders());
byte[] body = null;
InputStream stream = null;
entity = response.getEntity();
if (streamResponse) {
stream = entity.getContent();
} else {
if(null != entity) {
body = EntityUtils.toByteArray(entity);
}
}
key = extractKeyFromResponseIfItWasNotAlreadyProvided(key, response);
return new DefaultHttpResponse(bucket, key, status, headers, body, stream, response, httpMethod);
} catch (IOException e) {
httpMethod.abort();
return toss(new RiakIORuntimeException(e));
} finally {
if(!streamResponse && entity != null) {
try {
EntityUtils.consume(entity);
} catch (IOException e) {