public class NHttpConnectionBase extends Object implements NHttpConnection, HttpInetConnection, SessionBufferStatus, SocketAccessor
NHttpConnection implementations and provides
functionality common to both client and server HTTP connections.ACTIVE, CLOSED, CLOSING| Constructor and Description |
|---|
NHttpConnectionBase(IOSession session,
ByteBufferAllocator allocator,
HttpParams params)
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this connection gracefully.
|
HttpContext |
getContext()
Returns an HTTP execution context associated with this connection.
|
HttpRequest |
getHttpRequest()
Returns the current HTTP request if one is being received / transmitted.
|
HttpResponse |
getHttpResponse()
Returns the current HTTP response if one is being received / transmitted.
|
InetAddress |
getLocalAddress() |
int |
getLocalPort() |
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrics.
|
InetAddress |
getRemoteAddress() |
int |
getRemotePort() |
Socket |
getSocket()
Return the underlying socket
|
int |
getSocketTimeout()
Returns the socket timeout value.
|
int |
getStatus()
Returns status of the connection:
|
boolean |
hasBufferedInput()
Determines if the session input buffer contains data.
|
boolean |
hasBufferedOutput()
Determines if the session output buffer contains data.
|
boolean |
isOpen()
Checks if this connection is open.
|
boolean |
isStale()
Checks whether this connection has gone down.
|
void |
requestInput()
Requests event notifications to be triggered when the underlying
channel is ready for input operations.
|
void |
requestOutput()
Requests event notifications to be triggered when the underlying
channel is ready for output operations.
|
void |
setSocketTimeout(int timeout)
Sets the socket timeout value.
|
void |
shutdown()
Force-closes this connection.
|
void |
suspendInput()
Suspends event notifications about the underlying channel being
ready for input operations.
|
void |
suspendOutput()
Suspends event notifications about the underlying channel being
ready for output operations.
|
String |
toString() |
@Deprecated public NHttpConnectionBase(IOSession session, ByteBufferAllocator allocator, HttpParams params)
NHttpConnectionBase(IOSession, int, int, ByteBufferAllocator,
CharsetDecoder, CharsetEncoder, ContentLengthStrategy, ContentLengthStrategy)session - the underlying I/O session.allocator - byte buffer allocator.params - HTTP parameters.public int getStatus()
NHttpConnection
NHttpConnection.ACTIVE: connection is active.
NHttpConnection.CLOSING: connection is being closed.
NHttpConnection.CLOSED: connection has been closed.
getStatus in interface NHttpConnectionpublic HttpContext getContext()
NHttpConnectiongetContext in interface NHttpConnectionpublic HttpRequest getHttpRequest()
NHttpConnectionnull.getHttpRequest in interface NHttpConnectionnull otherwise.public HttpResponse getHttpResponse()
NHttpConnectionnull.getHttpResponse in interface NHttpConnectionnull otherwise.public void requestInput()
IOControlrequestInput in interface IOControlpublic void requestOutput()
IOControlrequestOutput in interface IOControlpublic void suspendInput()
IOControlsuspendInput in interface IOControlpublic void suspendOutput()
IOControlsuspendOutput in interface IOControlpublic boolean hasBufferedInput()
SessionBufferStatushasBufferedInput in interface SessionBufferStatustrue if the session input buffer contains data,
false otherwise.public boolean hasBufferedOutput()
SessionBufferStatushasBufferedOutput in interface SessionBufferStatustrue if the session output buffer contains data,
false otherwise.public void close()
throws IOException
HttpConnectionshutdown instead.close in interface Closeableclose in interface AutoCloseableclose in interface HttpConnectionIOExceptionpublic boolean isOpen()
HttpConnectionisOpen in interface HttpConnectionpublic boolean isStale()
HttpConnectionisStale in interface HttpConnectiontrue if attempts to use this connection are
likely to succeed, or false if they are likely
to fail and this connection should be closedpublic InetAddress getLocalAddress()
getLocalAddress in interface HttpInetConnectionpublic int getLocalPort()
getLocalPort in interface HttpInetConnectionpublic InetAddress getRemoteAddress()
getRemoteAddress in interface HttpInetConnectionpublic int getRemotePort()
getRemotePort in interface HttpInetConnectionpublic void setSocketTimeout(int timeout)
HttpConnectionsetSocketTimeout in interface HttpConnectiontimeout - timeout value in millisecondspublic int getSocketTimeout()
HttpConnectiongetSocketTimeout in interface HttpConnection0 if timeout is disabled or -1 if
timeout is undefined.public void shutdown()
throws IOException
HttpConnectionshutdown in interface HttpConnectionshutdown in interface IOControlIOException - in an error occurspublic HttpConnectionMetrics getMetrics()
HttpConnectiongetMetrics in interface HttpConnectionpublic Socket getSocket()
SocketAccessorgetSocket in interface SocketAccessornull.Copyright © 2010 - 2020 Adobe. All Rights Reserved