/** * @param response The response to parse * @return A HttpResponse object made by consuming the response of the * given HttpMethod. * @throws IOException when problems occur processing the body content */ private HttpResponse makeResponse(org.apache.http.HttpResponse response) throws IOException { HttpResponseBuilder builder = new HttpResponseBuilder(); if (response.getAllHeaders() != null) { for (Header h : response.getAllHeaders()) { if (h.getName() != null) builder.addHeader(h.getName(), h.getValue()); } } HttpEntity entity = response.getEntity(); if (maxObjSize > 0 && entity != null && entity.getContentLength() > maxObjSize) { return HttpResponse.badrequest("Exceeded maximum number of bytes - " + maxObjSize); } byte[] responseBytes = (entity == null) ? null : toByteArraySafe(entity); return builder .setHttpStatusCode(response.getStatusLine().getStatusCode()) .setResponse(responseBytes) .create(); }
/** * @param response The response to parse * @return A HttpResponse object made by consuming the response of the * given HttpMethod. * @throws IOException when problems occur processing the body content */ private HttpResponse makeResponse(org.apache.http.HttpResponse response) throws IOException { HttpResponseBuilder builder = new HttpResponseBuilder(); if (response.getAllHeaders() != null) { for (Header h : response.getAllHeaders()) { if (h.getName() != null) builder.addHeader(h.getName(), h.getValue()); } } HttpEntity entity = response.getEntity(); if (maxObjSize > 0 && entity != null && entity.getContentLength() > maxObjSize) { return HttpResponse.badrequest("Exceeded maximum number of bytes - " + maxObjSize); } byte[] responseBytes = (entity == null) ? null : toByteArraySafe(entity); return builder .setHttpStatusCode(response.getStatusLine().getStatusCode()) .setResponse(responseBytes) .create(); }
/** * @param response The response to parse * @return A HttpResponse object made by consuming the response of the * given HttpMethod. * @throws IOException when problems occur processing the body content */ private HttpResponse makeResponse(org.apache.http.HttpResponse response) throws IOException { HttpResponseBuilder builder = new HttpResponseBuilder(); if (response.getAllHeaders() != null) { for (Header h : response.getAllHeaders()) { if (h.getName() != null) builder.addHeader(h.getName(), h.getValue()); } } HttpEntity entity = response.getEntity(); if (maxObjSize > 0 && entity.getContentLength() > maxObjSize) { return HttpResponse.badrequest("Exceeded maximum number of bytes - " + maxObjSize); } byte[] responseBytes = (entity == null) ? null : toByteArraySafe(entity); return builder .setHttpStatusCode(response.getStatusLine().getStatusCode()) .setResponse(responseBytes) .create(); }