code: public static HttpEntity createEntity(HttpResponse response) throws IOException {
  		ByteArrayInputStream is = new ByteArrayInputStream(
  				EntityUtils.toByteArray(response.getEntity()));
  		BasicHttpEntity entity = new BasicHttpEntity();
  		entity.setContent(is);
  		entity.setContentLength(response.getEntity().getContentLength());
  		if (CloseableHttpResponse.class.isInstance(response)) {
  			((CloseableHttpResponse) response).close();
  		}
  		return entity;
  	}
docs: Creates an new {@link HttpEntity} by copying the {@link HttpEntity} from the
  {@link HttpResponse}. This method will close the response after copying the entity.
  @param response The response to create the {@link HttpEntity} from
  @return A new {@link HttpEntity}
  @throws IOException thrown if there is a problem closing the response.