|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.http.impl.BHttpConnectionBase
public class BHttpConnectionBase
This class serves as a base for all HttpConnection
implementations
and provides functionality common to both client and server HTTP connections.
Constructor Summary | |
---|---|
protected |
BHttpConnectionBase(int bufferSize,
int fragmentSizeHint,
CharsetDecoder charDecoder,
CharsetEncoder charEncoder,
MessageConstraints messageConstraints,
ContentLengthStrategy incomingContentStrategy,
ContentLengthStrategy outgoingContentStrategy)
Creates new instance of BHttpConnectionBase. |
Method Summary | |
---|---|
protected boolean |
awaitInput(int timeout)
|
protected void |
bind(Socket socket)
Binds this connection to the given Socket . |
void |
close()
Closes this connection gracefully. |
protected InputStream |
createInputStream(long len,
SessionInputBuffer inBuffer)
|
protected OutputStream |
createOutputStream(long len,
SessionOutputBuffer outbuffer)
|
protected void |
doFlush()
|
protected void |
ensureOpen()
|
InetAddress |
getLocalAddress()
|
int |
getLocalPort()
|
HttpConnectionMetrics |
getMetrics()
Returns a collection of connection metrics. |
InetAddress |
getRemoteAddress()
|
int |
getRemotePort()
|
protected SessionInputBuffer |
getSessionInputBuffer()
|
protected SessionOutputBuffer |
getSessionOutputBuffer()
|
protected Socket |
getSocket()
|
protected InputStream |
getSocketInputStream(Socket socket)
|
protected OutputStream |
getSocketOutputStream(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 OutputStream |
prepareOutput(HttpMessage message)
|
void |
setSocketTimeout(int timeout)
Sets the socket timeout value. |
void |
shutdown()
Force-closes this connection. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected BHttpConnectionBase(int bufferSize, int fragmentSizeHint, CharsetDecoder charDecoder, 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.Method Detail |
---|
protected void ensureOpen() throws IOException
IOException
protected InputStream getSocketInputStream(Socket socket) throws IOException
IOException
protected OutputStream getSocketOutputStream(Socket socket) throws IOException
IOException
protected void bind(Socket socket) throws 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.
IOException
- in case of an I/O error.protected SessionInputBuffer getSessionInputBuffer()
protected SessionOutputBuffer getSessionOutputBuffer()
protected void doFlush() throws IOException
IOException
public boolean isOpen()
HttpConnection
isOpen
in interface HttpConnection
protected Socket getSocket()
protected OutputStream createOutputStream(long len, SessionOutputBuffer outbuffer)
protected OutputStream prepareOutput(HttpMessage message) throws HttpException
HttpException
protected InputStream createInputStream(long len, SessionInputBuffer inBuffer)
protected HttpEntity prepareInput(HttpMessage message) throws HttpException
HttpException
public InetAddress getLocalAddress()
getLocalAddress
in interface HttpInetConnection
public int getLocalPort()
getLocalPort
in interface HttpInetConnection
public InetAddress getRemoteAddress()
getRemoteAddress
in interface HttpInetConnection
public int getRemotePort()
getRemotePort
in interface HttpInetConnection
public void setSocketTimeout(int timeout)
HttpConnection
setSocketTimeout
in interface HttpConnection
timeout
- timeout value in millisecondspublic int getSocketTimeout()
HttpConnection
getSocketTimeout
in interface HttpConnection
0
if timeout is disabled or -1
if
timeout is undefined.public void shutdown() throws IOException
HttpConnection
shutdown
in interface HttpConnection
IOException
public void close() throws IOException
HttpConnection
shutdown
instead.
close
in interface Closeable
close
in interface HttpConnection
IOException
protected boolean awaitInput(int timeout) throws IOException
IOException
public boolean isStale()
HttpConnection
isStale
in interface HttpConnection
true
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()
HttpConnection
getMetrics
in interface HttpConnection
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |