Example usage for org.apache.http.nio.conn ManagedClientAsyncConnection releaseConnection

List of usage examples for org.apache.http.nio.conn ManagedClientAsyncConnection releaseConnection

Introduction

In this page you can find the example usage for org.apache.http.nio.conn ManagedClientAsyncConnection releaseConnection.

Prototype

void releaseConnection() throws IOException;

Source Link

Document

Releases the connection with the option of keep-alive.

Usage

From source file:org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.java

private synchronized void connectionRequestCompleted(final ManagedClientAsyncConnection conn) {
    if (this.log.isDebugEnabled()) {
        this.log.debug("[exchange: " + this.id + "] Connection allocated: " + conn);
    }//from   w ww . j a  va2  s.  c  o  m
    this.connRequestCallback = null;
    try {
        this.managedConn = conn;
        if (this.closed) {
            conn.releaseConnection();
            return;
        }
        final HttpRoute route = this.mainRequest.getRoute();
        if (!conn.isOpen()) {
            conn.open(route, this.localContext, this.params);
        }
        conn.getContext().setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, this);
        conn.requestOutput();
        this.routeEstablished = route.equals(conn.getRoute());
        if (!conn.isOpen()) {
            throw new ConnectionClosedException("Connection closed");
        }
    } catch (final IOException ex) {
        failed(ex);
    } catch (final RuntimeException runex) {
        failed(runex);
        throw runex;
    }
}