List of usage examples for org.apache.http.util EntityUtils consumeQuietly
public static void consumeQuietly(HttpEntity httpEntity)
From source file:org.commonjava.maven.galley.transport.htcli.util.HttpUtil.java
public static void cleanupResources(final CloseableHttpClient client, final HttpUriRequest request, final CloseableHttpResponse response) { if (response != null && response.getEntity() != null) { EntityUtils.consumeQuietly(response.getEntity()); closeQuietly(response);//www. j a v a 2 s.c o m } if (request != null) { if (request instanceof AbstractExecutionAwareRequest) { ((AbstractExecutionAwareRequest) request).reset(); } } if (client != null) { closeQuietly(client); } }
From source file:org.keycloak.adapters.cloned.HttpAdapterUtils.java
public static MultivaluedHashMap<String, KeyInfo> downloadKeysFromSamlDescriptor(HttpClient client, String descriptorUrl) throws HttpClientAdapterException { try {/*from w ww . j av a 2 s.c o m*/ HttpGet httpRequest = new HttpGet(descriptorUrl); HttpResponse response = client.execute(httpRequest); int status = response.getStatusLine().getStatusCode(); if (status != HttpStatus.SC_OK) { EntityUtils.consumeQuietly(response.getEntity()); throw new HttpClientAdapterException("Unexpected status = " + status); } HttpEntity entity = response.getEntity(); if (entity == null) { throw new HttpClientAdapterException("There was no entity."); } MultivaluedHashMap<String, KeyInfo> res; try (InputStream is = entity.getContent()) { res = extractKeysFromSamlDescriptor(is); } EntityUtils.consumeQuietly(entity); return res; } catch (IOException | ParsingException e) { throw new HttpClientAdapterException("IO error", e); } }
From source file:httputils.HttpUtil.java
/** * * @param response//from ww w .java 2s.c o m * @return true if no error, false if error */ public static boolean verifyResponseAndConsume(HttpResponse response) { boolean retVal = verifyResponseWithoutConsuming(response); EntityUtils.consumeQuietly(response.getEntity()); return retVal; }
From source file:org.callimachusproject.server.helpers.EntityRemovedHttpResponse.java
@Override public void setEntity(HttpEntity entity) { HttpEntity previously = getEntity(); if (entity == null && previously != null) { EntityUtils.consumeQuietly(previously); }/*from w w w . ja v a 2 s . com*/ super.setEntity(entity); }
From source file:org.callimachusproject.server.chain.HeadRequestFilter.java
@Override public void process(HttpResponse response, HttpContext context) throws HttpException, IOException { HttpRequest request = HttpCoreContext.adapt(context).getRequest(); HttpEntity entity = response.getEntity(); if (request != null && "HEAD".equals(request.getRequestLine().getMethod()) && entity != null) { EntityUtils.consumeQuietly(entity); response.setEntity(null);/* w ww.ja va2 s .c o m*/ } }
From source file:org.apache.hadoop.gateway.shell.BasicResponse.java
public void consume() { if (!consumed) { EntityUtils.consumeQuietly(response.getEntity()); consumed = true; } }
From source file:de.ii.xtraplatform.ogc.api.gml.parser.GMLDictionaryParser.java
public void parse(HttpEntity entity) { try {//from w ww .j a v a 2 s . c o m InputSource is = new InputSource(entity.getContent()); parse(is); } catch (IOException ex) { // TODO: move to analyzer for XtraProxy //LOGGER.error(FrameworkMessages.ERROR_PARSING_WFS_CAPABILITIES); //throw new SchemaParseException(FrameworkMessages.ERROR_PARSING_WFS_CAPABILITIES); analyzer.analyzeFailed(ex); } finally { EntityUtils.consumeQuietly(entity); } }
From source file:org.commonjava.aprox.subsys.http.util.HttpResources.java
public static void cleanupResources(final HttpRequest request, final HttpResponse response, final CloseableHttpClient client, final AproxHttpProvider http) { if (response != null && response.getEntity() != null) { EntityUtils.consumeQuietly(response.getEntity()); if (response instanceof CloseableHttpResponse) { closeQuietly((CloseableHttpResponse) response); }//from w w w .jav a 2 s. c o m } if (request != null) { if (request instanceof AbstractExecutionAwareRequest) { ((AbstractExecutionAwareRequest) request).reset(); } } if (client != null) { closeQuietly(client); } http.clearRepositoryCredentials(); http.closeConnection(); }
From source file:HttpResponseBackedInputStream.java
@Override public void close() throws IOException { // Close the backing inputStream. super.close(); this.backingStream.close(); // Fully consume the backing HTTP response. EntityUtils.consumeQuietly(httpResponse.getEntity()); /*//from w ww . ja va 2s. c o m * Don't actually close the HTTP response, as this prevents it from being re-used, * negatively impacting performance. */ //this.httpResponse.close(); }
From source file:org.jasig.portlet.proxy.service.web.HttpContentResponseImpl.java
@Override public void close() { EntityUtils.consumeQuietly(entity); }