@NotThreadSafe public class BHttpConnectionBase extends java.lang.Object implements HttpConnection, HttpInetConnection
HttpConnection implementations and provides
functionality common to both client and server HTTP connections.| Modifier | Constructor and Description |
|---|---|
protected |
BHttpConnectionBase(int buffersize,
int fragmentSizeHint,
java.nio.charset.CharsetDecoder chardecoder,
java.nio.charset.CharsetEncoder charencoder,
MessageConstraints messageConstraints,
ContentLengthStrategy incomingContentStrategy,
ContentLengthStrategy outgoingContentStrategy)
Creates new instance of BHttpConnectionBase.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
awaitInput(int timeout) |
protected void |
bind(java.net.Socket socket)
Binds this connection to the given
Socket. |
void |
close()
Closes this connection gracefully.
|
protected java.io.InputStream |
createInputStream(long len,
SessionInputBuffer inbuffer) |
protected java.io.OutputStream |
createOutputStream(long len,
SessionOutputBuffer outbuffer) |
protected void |
doFlush() |
protected void |
ensureOpen() |
java.net.InetAddress |
getLocalAddress() |
int |
getLocalPort() |
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrics.
|
java.net.InetAddress |
getRemoteAddress() |
int |
getRemotePort() |
protected SessionInputBuffer |
getSessionInputBuffer() |
protected SessionOutputBuffer |
getSessionOutputBuffer() |
protected java.net.Socket |
getSocket() |
protected java.io.InputStream |
getSocketInputStream(java.net.Socket socket) |
protected java.io.OutputStream |
getSocketOutputStream(java.net.Socket socket) |
int |
getSocketTimeout()
Returns the socket timeout value.
|
protected void |
incrementRequestCount() |
protected void |
incrementResponseCount() |
boolean |
isOpen()
Checks if this connection is open.
|
boolean |
isStale()
Checks whether this connection has gone down.
|
protected HttpEntity |
prepareInput(HttpMessage message) |
protected java.io.OutputStream |
prepareOutput(HttpMessage message) |
void |
setSocketTimeout(int timeout)
Sets the socket timeout value.
|
void |
shutdown()
Force-closes this connection.
|
java.lang.String |
toString() |
protected BHttpConnectionBase(int buffersize,
int fragmentSizeHint,
java.nio.charset.CharsetDecoder chardecoder,
java.nio.charset.CharsetEncoder charencoder,
MessageConstraints messageConstraints,
ContentLengthStrategy incomingContentStrategy,
ContentLengthStrategy outgoingContentStrategy)
buffersize - buffer size. Must be a positive number.fragmentSizeHint - fragment size hint.chardecoder - decoder to be used for decoding HTTP protocol elements.
If null simple type cast will be used for byte to char conversion.charencoder - encoder to be used for encoding HTTP protocol elements.
If null simple type cast will be used for char to byte conversion.messageConstraints - Message constraints. If null
MessageConstraints.DEFAULT will be used.incomingContentStrategy - incoming content length strategy. If null
LaxContentLengthStrategy.INSTANCE will be used.outgoingContentStrategy - outgoing content length strategy. If null
StrictContentLengthStrategy.INSTANCE will be used.protected void ensureOpen()
throws java.io.IOException
java.io.IOExceptionprotected java.io.InputStream getSocketInputStream(java.net.Socket socket)
throws java.io.IOException
java.io.IOExceptionprotected java.io.OutputStream getSocketOutputStream(java.net.Socket socket)
throws java.io.IOException
java.io.IOExceptionprotected void bind(java.net.Socket socket)
throws java.io.IOException
Socket. This socket will be
used by the connection to send and receive data.
After this method's execution the connection status will be reported
as open and the isOpen() will return true.
socket - the socket.java.io.IOException - in case of an I/O error.protected SessionInputBuffer getSessionInputBuffer()
protected SessionOutputBuffer getSessionOutputBuffer()
protected void doFlush()
throws java.io.IOException
java.io.IOExceptionpublic boolean isOpen()
HttpConnectionisOpen in interface HttpConnectionprotected java.net.Socket getSocket()
protected java.io.OutputStream createOutputStream(long len,
SessionOutputBuffer outbuffer)
protected java.io.OutputStream prepareOutput(HttpMessage message) throws HttpException
HttpExceptionprotected java.io.InputStream createInputStream(long len,
SessionInputBuffer inbuffer)
protected HttpEntity prepareInput(HttpMessage message) throws HttpException
HttpExceptionpublic java.net.InetAddress getLocalAddress()
getLocalAddress in interface HttpInetConnectionpublic int getLocalPort()
getLocalPort in interface HttpInetConnectionpublic java.net.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 java.io.IOException
HttpConnectionshutdown in interface HttpConnectionjava.io.IOExceptionpublic void close()
throws java.io.IOException
HttpConnectionshutdown instead.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface HttpConnectionjava.io.IOExceptionprotected boolean awaitInput(int timeout)
throws java.io.IOException
java.io.IOExceptionpublic 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 closedprotected void incrementRequestCount()
protected void incrementResponseCount()
public HttpConnectionMetrics getMetrics()
HttpConnectiongetMetrics in interface HttpConnectionpublic java.lang.String toString()
toString in class java.lang.Object