public class DefaultBHttpClientConnection extends Object implements HttpClientConnection
HttpClientConnection.| 限定符和类型 | 方法和说明 |
|---|---|
protected boolean |
awaitInput(Timeout timeout) |
void |
bind(Socket socket)
Binds this connection to the given
Socket. |
protected void |
bind(SocketHolder socketHolder) |
void |
close()
Closes this connection gracefully.
|
void |
close(CloseMode closeMode)
Closes this process or endpoint and releases any system resources associated
with it.
|
protected InputStream |
createContentInputStream(long len,
SessionInputBuffer buffer,
InputStream inputStream) |
protected OutputStream |
createContentOutputStream(long len,
SessionOutputBuffer buffer,
OutputStream outputStream,
Supplier<List<? extends Header>> trailers) |
protected SocketHolder |
ensureOpen() |
void |
flush()
Writes out all pending buffered data over the open connection.
|
EndpointDetails |
getEndpointDetails()
Returns this connection's endpoint details.
|
SocketAddress |
getLocalAddress()
Returns this connection's local address or
null if it is not bound yet. |
ProtocolVersion |
getProtocolVersion()
Returns this connection's protocol version or
null if unknown. |
SocketAddress |
getRemoteAddress()
Returns this connection's remote address or
null if it is not connected yet or
unconnected. |
protected SocketHolder |
getSocketHolder() |
Timeout |
getSocketTimeout()
Returns the socket timeout value.
|
SSLSession |
getSSLSession()
Returns this connection's SSL session or
null if TLS has not been activated. |
protected void |
incrementRequestCount() |
protected void |
incrementResponseCount() |
boolean |
isConsistent()
Checks whether this connection is in a consistent state.
|
boolean |
isDataAvailable(Timeout timeout)
Checks if input data is available from the connection.
|
boolean |
isOpen()
Checks if this connection is open.
|
boolean |
isStale()
Checks whether this connection has gone down.
|
protected void |
onRequestSubmitted(ClassicHttpRequest request) |
protected void |
onResponseReceived(ClassicHttpResponse response) |
void |
receiveResponseEntity(ClassicHttpResponse response)
Receives the next response entity available from this connection and
attaches it to an existing HttpResponse object.
|
ClassicHttpResponse |
receiveResponseHeader()
Receives the request line and headers of the next response available from
this connection.
|
void |
sendRequestEntity(ClassicHttpRequest request)
Sends the request entity over the connection.
|
void |
sendRequestHeader(ClassicHttpRequest request)
Sends the request line and all headers over the connection.
|
void |
setSocketTimeout(Timeout timeout)
Sets the socket timeout value.
|
void |
terminateRequest(ClassicHttpRequest request)
Terminates request prematurely potentially leaving
the connection in a inconsistent state.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitflush, isDataAvailable, isStaleclose, getEndpointDetails, getLocalAddress, getProtocolVersion, getRemoteAddress, getSSLSession, isOpengetSocketTimeout, setSocketTimeoutclosepublic DefaultBHttpClientConnection(Http1Config http1Config, CharsetDecoder charDecoder, CharsetEncoder charEncoder, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, ResponseOutOfOrderStrategy responseOutOfOrderStrategy, HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory, HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory)
http1Config - Message http1Config. If null
Http1Config.DEFAULT will be used.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.incomingContentStrategy - incoming content length strategy. If null
DefaultContentLengthStrategy.INSTANCE will be used.outgoingContentStrategy - outgoing content length strategy. If null
DefaultContentLengthStrategy.INSTANCE will be used.responseOutOfOrderStrategy - response out of order strategy. If null
NoResponseOutOfOrderStrategy.INSTANCE will be used.requestWriterFactory - request writer factory. If null
DefaultHttpRequestWriterFactory.INSTANCE will be used.responseParserFactory - response parser factory. If null
DefaultHttpResponseParserFactory.INSTANCE will be used.public DefaultBHttpClientConnection(Http1Config http1Config, CharsetDecoder charDecoder, CharsetEncoder charEncoder, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory, HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory)
http1Config - Message http1Config. If null
Http1Config.DEFAULT will be used.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.incomingContentStrategy - incoming content length strategy. If null
DefaultContentLengthStrategy.INSTANCE will be used.outgoingContentStrategy - outgoing content length strategy. If null
DefaultContentLengthStrategy.INSTANCE will be used.requestWriterFactory - request writer factory. If null
DefaultHttpRequestWriterFactory.INSTANCE will be used.responseParserFactory - response parser factory. If null
DefaultHttpResponseParserFactory.INSTANCE will be used.public DefaultBHttpClientConnection(Http1Config http1Config, CharsetDecoder charDecoder, CharsetEncoder charEncoder)
public DefaultBHttpClientConnection(Http1Config http1Config)
protected void onResponseReceived(ClassicHttpResponse response)
protected void onRequestSubmitted(ClassicHttpRequest request)
public 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.public void sendRequestHeader(ClassicHttpRequest request) throws HttpException, IOException
HttpClientConnectionsendRequestHeader 在接口中 HttpClientConnectionrequest - the request whose headers to send.HttpException - in case of HTTP protocol violationIOException - in case of an I/O errorpublic void sendRequestEntity(ClassicHttpRequest request) throws HttpException, IOException
HttpClientConnectionsendRequestEntity 在接口中 HttpClientConnectionrequest - the request whose entity to send.HttpException - in case of HTTP protocol violationIOException - in case of an I/O errorpublic boolean isConsistent()
HttpClientConnectionisConsistent 在接口中 HttpClientConnectiontrue if the connection is known to be
in a inconsistent state and cannot be re-used.HttpClientConnection.terminateRequest(ClassicHttpRequest)public void terminateRequest(ClassicHttpRequest request) throws HttpException, IOException
HttpClientConnectionterminateRequest 在接口中 HttpClientConnectionrequest - the request to be terminated prematurely.HttpExceptionIOExceptionHttpClientConnection.isConsistent()public ClassicHttpResponse receiveResponseHeader() throws HttpException, IOException
HttpClientConnectionreceiveResponseHeader 在接口中 HttpClientConnectionnull if the connection has been closed
by the opposite endpoint.HttpException - in case of HTTP protocol violationIOException - in case of an I/O errorpublic void receiveResponseEntity(ClassicHttpResponse response) throws HttpException, IOException
HttpClientConnectionreceiveResponseEntity 在接口中 HttpClientConnectionresponse - the response to attach the entity toHttpException - in case of HTTP protocol violationIOException - in case of an I/O errorprotected SocketHolder ensureOpen() throws IOException
IOExceptionprotected void bind(SocketHolder socketHolder) throws IOException
IOExceptionpublic boolean isOpen()
HttpConnectionisOpen 在接口中 HttpConnectionpublic ProtocolVersion getProtocolVersion()
HttpConnectionnull if unknown.getProtocolVersion 在接口中 HttpConnectionnull if unknown.protected SocketHolder getSocketHolder()
protected OutputStream createContentOutputStream(long len, SessionOutputBuffer buffer, OutputStream outputStream, Supplier<List<? extends Header>> trailers)
protected InputStream createContentInputStream(long len, SessionInputBuffer buffer, InputStream inputStream)
public SocketAddress getRemoteAddress()
HttpConnectionnull if it is not connected yet or
unconnected.getRemoteAddress 在接口中 HttpConnectionnull if it is not connected yet or
unconnected.public SocketAddress getLocalAddress()
HttpConnectionnull if it is not bound yet.getLocalAddress 在接口中 HttpConnectionnull if it is not bound yet.public void setSocketTimeout(Timeout timeout)
SocketModalCloseablesetSocketTimeout 在接口中 SocketModalCloseabletimeout - timeout valuepublic Timeout getSocketTimeout()
SocketModalCloseablegetSocketTimeout 在接口中 SocketModalCloseablepublic void close(CloseMode closeMode)
ModalCloseableclose 在接口中 ModalCloseablecloseMode - How to close the receiver.public void close()
throws IOException
HttpConnectionshutdown instead.close 在接口中 Closeableclose 在接口中 AutoCloseableclose 在接口中 HttpConnectionIOExceptionprotected boolean awaitInput(Timeout timeout) throws IOException
IOExceptionpublic boolean isDataAvailable(Timeout timeout) throws IOException
BHttpConnectionisDataAvailable 在接口中 BHttpConnectiontimeout - the maximum time to wait for datatimeout.IOException - if an error happens on the connectionpublic boolean isStale()
throws IOException
BHttpConnectionisStale 在接口中 BHttpConnectiontrue if attempts to use this connection are likely
to fail and this connection should be closed,
or false if they are likely to succeedIOExceptionpublic void flush()
throws IOException
BHttpConnectionflush 在接口中 BHttpConnectionIOException - in case of an I/O errorprotected void incrementRequestCount()
protected void incrementResponseCount()
public SSLSession getSSLSession()
HttpConnectionnull if TLS has not been activated.getSSLSession 在接口中 HttpConnectionnull if TLS has not been activated.public EndpointDetails getEndpointDetails()
HttpConnectiongetEndpointDetails 在接口中 HttpConnectionCopyright © 2023. All rights reserved.