|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.http.impl.nio.NHttpConnectionBase
public class NHttpConnectionBase
This class serves as a base for all NHttpConnection implementations
and implements functionality common to both client and server
HTTP connections.
| Field Summary | |
|---|---|
protected HttpConnectionMetricsImpl |
connMetrics
|
protected ContentDecoder |
contentDecoder
|
protected ContentEncoder |
contentEncoder
|
protected HttpContext |
context
|
protected boolean |
hasBufferedInput
|
protected boolean |
hasBufferedOutput
|
protected SessionInputBufferImpl |
inbuf
|
protected ContentLengthStrategy |
incomingContentStrategy
|
protected HttpTransportMetricsImpl |
inTransportMetrics
|
protected SessionOutputBufferImpl |
outbuf
|
protected ContentLengthStrategy |
outgoingContentStrategy
|
protected HttpTransportMetricsImpl |
outTransportMetrics
|
protected HttpRequest |
request
|
protected HttpResponse |
response
|
protected IOSession |
session
|
protected int |
status
|
| Fields inherited from interface org.apache.http.nio.NHttpConnection |
|---|
ACTIVE, CLOSED, CLOSING |
| Constructor Summary | |
|---|---|
NHttpConnectionBase(IOSession session,
ByteBufferAllocator allocator,
HttpParams params)
Creates a new instance of this class given the underlying I/O session. |
|
| Method Summary | |
|---|---|
protected void |
assertNotClosed()
Assets if the connection is still open. |
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()
|
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. |
protected HttpEntity |
prepareDecoder(HttpMessage message)
Initializes a specific ContentDecoder implementation based on the
properties of the given HttpMessage and generates an instance of
HttpEntity matching the properties of the content decoder. |
protected void |
prepareEncoder(HttpMessage message)
Initializes a specific ContentEncoder implementation based on the
properties of the given HttpMessage. |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final HttpContext context
protected final ContentLengthStrategy incomingContentStrategy
protected final ContentLengthStrategy outgoingContentStrategy
protected final SessionInputBufferImpl inbuf
protected final SessionOutputBufferImpl outbuf
protected final HttpTransportMetricsImpl inTransportMetrics
protected final HttpTransportMetricsImpl outTransportMetrics
protected final HttpConnectionMetricsImpl connMetrics
protected IOSession session
protected volatile ContentDecoder contentDecoder
protected volatile boolean hasBufferedInput
protected volatile ContentEncoder contentEncoder
protected volatile boolean hasBufferedOutput
protected volatile HttpRequest request
protected volatile HttpResponse response
protected volatile int status
| Constructor Detail |
|---|
public NHttpConnectionBase(IOSession session,
ByteBufferAllocator allocator,
HttpParams params)
The following HTTP parameters affect configuration of this connection:
The CoreConnectionPNames.SOCKET_BUFFER_SIZE
parameter determines the size of the internal socket buffer. If not
defined or set to -1 the default value will be chosen
automatically.
session - the underlying I/O session.allocator - byte buffer allocator.params - HTTP parameters.| Method Detail |
|---|
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()
NHttpConnection
getContext in interface NHttpConnectionpublic HttpRequest getHttpRequest()
NHttpConnectionnull.
getHttpRequest in interface NHttpConnectionnull otherwise.public HttpResponse getHttpResponse()
NHttpConnection
getHttpResponse in interface NHttpConnectionnull otherwise.public void requestInput()
IOControl
requestInput in interface IOControlpublic void requestOutput()
IOControl
requestOutput in interface IOControlpublic void suspendInput()
IOControl
suspendInput in interface IOControlpublic void suspendOutput()
IOControl
suspendOutput in interface IOControl
protected HttpEntity prepareDecoder(HttpMessage message)
throws HttpException
ContentDecoder implementation based on the
properties of the given HttpMessage and generates an instance of
HttpEntity matching the properties of the content decoder.
message - the HTTP message.
HttpException - in case of an HTTP protocol violation.
protected void prepareEncoder(HttpMessage message)
throws HttpException
ContentEncoder implementation based on the
properties of the given HttpMessage.
message - the HTTP message.
HttpException - in case of an HTTP protocol violation.public boolean hasBufferedInput()
SessionBufferStatus
hasBufferedInput in interface SessionBufferStatustrue if the session input buffer contains data,
false otherwise.public boolean hasBufferedOutput()
SessionBufferStatus
hasBufferedOutput in interface SessionBufferStatustrue if the session output buffer contains data,
false otherwise.
protected void assertNotClosed()
throws ConnectionClosedException
ConnectionClosedException - in case the connection has already
been closed.
public void close()
throws IOException
HttpConnectionshutdown instead.
close in interface HttpConnectionIOExceptionpublic boolean isOpen()
HttpConnection
isOpen in interface HttpConnectionpublic boolean isStale()
HttpConnection
isStale 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)
HttpConnection
setSocketTimeout in interface HttpConnectiontimeout - timeout value in millisecondspublic int getSocketTimeout()
HttpConnection
getSocketTimeout in interface HttpConnection0 if timeout is disabled or -1 if
timeout is undefined.
public void shutdown()
throws IOException
HttpConnection
shutdown in interface HttpConnectionshutdown in interface IOControlIOExceptionpublic HttpConnectionMetrics getMetrics()
HttpConnection
getMetrics in interface HttpConnection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||