Example usage for org.apache.http.nio NHttpConnection ACTIVE

List of usage examples for org.apache.http.nio NHttpConnection ACTIVE

Introduction

In this page you can find the example usage for org.apache.http.nio NHttpConnection ACTIVE.

Prototype

int ACTIVE

To view the source code for org.apache.http.nio NHttpConnection ACTIVE.

Click Source Link

Usage

From source file:org.jclouds.http.httpnio.pool.NioHttpCommandConnectionPool.java

@Override
public void shutdownConnection(NHttpConnection conn) {
    if (conn.getStatus() == NHttpConnection.ACTIVE) {
        try {/* w  w  w . ja  v  a2  s  . co m*/
            conn.shutdown();
        } catch (IOException e) {
            logger.error(e, "Error shutting down connection");
        }
    }
}

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

public void timeout(final NHttpClientConnection conn) {
    HttpContext context = conn.getContext();
    HttpExchange httpexchange = getHttpExchange(context);
    HttpAsyncExchangeHandler<?> handler = getHandler(context);
    if (this.log.isDebugEnabled()) {
        this.log.debug("Timeout " + formatState(conn, httpexchange));
    }//from  www.  jav a  2  s.co  m
    try {
        if (httpexchange.getRequestState() == MessageState.ACK) {
            continueRequest(conn, httpexchange);
            httpexchange.setRequestState(MessageState.BODY_STREAM);
        } else {
            if (conn.getStatus() == NHttpConnection.ACTIVE) {
                conn.close();
                if (conn.getStatus() == NHttpConnection.CLOSING) {
                    // Give the connection some grace time to
                    // close itself nicely
                    conn.setSocketTimeout(250);
                }
            } else {
                conn.shutdown();
            }
        }
    } catch (IOException ex) {
        if (this.log.isDebugEnabled()) {
            this.log.debug("I/O error: " + ex.getMessage(), ex);
        }
        shutdownConnection(conn);
        handler.failed(ex);
    }
}