/** * Forces the release of an HttpMethod's connection in a way that will * perform all the necessary cleanup through the correct use of HttpClient * methods. * * @throws IOException */ protected void releaseConnection() throws IOException { if (!alreadyReleased) { if (!underlyingStreamConsumed) { // Underlying input stream has not been consumed, abort method // to force connection to be closed and cleaned-up. if (httpRequest instanceof AbortableHttpRequest) { AbortableHttpRequest abortableHttpRequest = (AbortableHttpRequest)httpRequest; abortableHttpRequest.abort(); } } inputStream.close(); alreadyReleased = true; } }
private void abortQuietly(AbortableHttpRequest httpRequest) { if (httpRequest != null) { httpRequest.abort(); } }