Search in sources :

Example 6 with CloseMode

use of org.apache.hc.core5.io.CloseMode in project httpcomponents-core by apache.

the class AbstractHttp1StreamDuplexer method shutdownSession.

void shutdownSession(final Exception cause) {
    connState = ConnectionState.SHUTDOWN;
    try {
        terminate(cause);
    } finally {
        final CloseMode closeMode;
        if (cause instanceof ConnectionClosedException) {
            closeMode = CloseMode.GRACEFUL;
        } else if (cause instanceof IOException) {
            closeMode = CloseMode.IMMEDIATE;
        } else {
            closeMode = CloseMode.GRACEFUL;
        }
        ioSession.close(closeMode);
    }
}
Also used : CloseMode(org.apache.hc.core5.io.CloseMode) ConnectionClosedException(org.apache.hc.core5.http.ConnectionClosedException) IOException(java.io.IOException)

Aggregations

CloseMode (org.apache.hc.core5.io.CloseMode)4 IOException (java.io.IOException)3 ConnectionClosedException (org.apache.hc.core5.http.ConnectionClosedException)2 RawFrame (org.apache.hc.core5.http2.frame.RawFrame)2 Command (org.apache.hc.core5.reactor.Command)2 Timeout (org.apache.hc.core5.util.Timeout)2 File (java.io.File)1 SocketAddress (java.net.SocketAddress)1 ByteBuffer (java.nio.ByteBuffer)1 ByteChannel (java.nio.channels.ByteChannel)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Lock (java.util.concurrent.locks.Lock)1 SSLContext (javax.net.ssl.SSLContext)1 Header (org.apache.hc.core5.http.Header)1 HttpConnection (org.apache.hc.core5.http.HttpConnection)1 HttpRequest (org.apache.hc.core5.http.HttpRequest)1 HttpResponse (org.apache.hc.core5.http.HttpResponse)1 ProtocolException (org.apache.hc.core5.http.ProtocolException)1