Package org.apache.http.impl.nio
Class DefaultNHttpClientConnection
java.lang.Object
org.apache.http.impl.nio.NHttpConnectionBase
org.apache.http.impl.nio.DefaultNHttpClientConnection
- All Implemented Interfaces:
Closeable,AutoCloseable,HttpConnection,HttpInetConnection,IOControl,NHttpClientConnection,NHttpClientIOTarget,NHttpConnection,SessionBufferStatus,SocketAccessor
public class DefaultNHttpClientConnection
extends NHttpConnectionBase
implements NHttpClientIOTarget
Default implementation of the
NHttpClientConnection
interface.- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final NHttpMessageWriter<HttpRequest>protected final NHttpMessageParser<HttpResponse>Fields inherited from class org.apache.http.impl.nio.NHttpConnectionBase
connMetrics, contentDecoder, contentEncoder, context, hasBufferedInput, hasBufferedOutput, inbuf, incomingContentStrategy, inTransportMetrics, outbuf, outgoingContentStrategy, outTransportMetrics, remote, request, response, session, statusFields inherited from interface org.apache.http.nio.NHttpConnection
ACTIVE, CLOSED, CLOSING -
Constructor Summary
ConstructorsConstructorDescriptionDefaultNHttpClientConnection(IOSession session, int bufferSize) DefaultNHttpClientConnection(IOSession session, int bufferSize, int fragmentSizeHint, ByteBufferAllocator allocator, CharsetDecoder charDecoder, CharsetEncoder charEncoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, NHttpMessageWriterFactory<HttpRequest> requestWriterFactory, NHttpMessageParserFactory<HttpResponse> responseParserFactory) Creates new instance DefaultNHttpClientConnection given the underlying I/O session.DefaultNHttpClientConnection(IOSession session, int bufferSize, CharsetDecoder charDecoder, CharsetEncoder charEncoder, MessageConstraints constraints) DefaultNHttpClientConnection(IOSession session, HttpResponseFactory responseFactory, ByteBufferAllocator allocator, HttpParams params) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsumeInput(NHttpClientEventHandler handler) voidconsumeInput(NHttpClientHandler handler) Triggered when the connection is ready to consume input.protected NHttpMessageWriter<HttpRequest>createRequestWriter(SessionOutputBuffer buffer, HttpParams params) Deprecated.(4.3) use constructor.protected NHttpMessageParser<HttpResponse>createResponseParser(SessionInputBuffer buffer, HttpResponseFactory responseFactory, HttpParams params) Deprecated.(4.3) use constructor.booleanReturnstrueif an HTTP request has been submitted to the target server.protected voidonRequestSubmitted(HttpRequest request) protected voidonResponseReceived(HttpResponse response) voidproduceOutput(NHttpClientEventHandler handler) voidproduceOutput(NHttpClientHandler handler) Triggered when the connection is ready to produce output.voidResets input state.voidResets output state.voidsubmitRequest(HttpRequest request) SubmitsHttpRequestto be sent to the target server.Methods inherited from class org.apache.http.impl.nio.NHttpConnectionBase
assertNotClosed, bind, close, createConnectionMetrics, createContentDecoder, createContentEncoder, createIncomingContentStrategy, createOutgoingContentStrategy, createTransportMetrics, getContext, getHttpRequest, getHttpResponse, getLocalAddress, getLocalPort, getMetrics, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, getStatus, hasBufferedInput, hasBufferedOutput, isOpen, isStale, prepareDecoder, prepareEncoder, requestInput, requestOutput, setSocketTimeout, shutdown, suspendInput, suspendOutput, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdownMethods inherited from interface org.apache.http.nio.IOControl
requestInput, requestOutput, shutdown, suspendInput, suspendOutputMethods inherited from interface org.apache.http.nio.NHttpConnection
getContext, getHttpRequest, getHttpResponse, getStatus
-
Field Details
-
responseParser
-
requestWriter
-
-
Constructor Details
-
DefaultNHttpClientConnection
@Deprecated public DefaultNHttpClientConnection(IOSession session, HttpResponseFactory responseFactory, ByteBufferAllocator allocator, HttpParams params) Creates a new instance of this class given the underlying I/O session.- Parameters:
session- the underlying I/O session.responseFactory- HTTP response factory.allocator- byte buffer allocator.params- HTTP parameters.
-
DefaultNHttpClientConnection
public DefaultNHttpClientConnection(IOSession session, int bufferSize, int fragmentSizeHint, ByteBufferAllocator allocator, CharsetDecoder charDecoder, CharsetEncoder charEncoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, NHttpMessageWriterFactory<HttpRequest> requestWriterFactory, NHttpMessageParserFactory<HttpResponse> responseParserFactory) Creates new instance DefaultNHttpClientConnection given the underlying I/O session.- Parameters:
session- the underlying I/O session.bufferSize- buffer size. Must be a positive number.fragmentSizeHint- fragment size hint.allocator- memory allocator. IfnullHeapByteBufferAllocator.INSTANCEwill be used.charDecoder- decoder to be used for decoding HTTP protocol elements. Ifnullsimple type cast will be used for byte to char conversion.charEncoder- encoder to be used for encoding HTTP protocol elements. Ifnullsimple type cast will be used for char to byte conversion.constraints- Message constraints. IfnullMessageConstraints.DEFAULTwill be used.incomingContentStrategy- incoming content length strategy. IfnullLaxContentLengthStrategy.INSTANCEwill be used.outgoingContentStrategy- outgoing content length strategy. IfnullStrictContentLengthStrategy.INSTANCEwill be used.- Since:
- 4.3
-
DefaultNHttpClientConnection
public DefaultNHttpClientConnection(IOSession session, int bufferSize, CharsetDecoder charDecoder, CharsetEncoder charEncoder, MessageConstraints constraints) - Since:
- 4.3
-
DefaultNHttpClientConnection
- Since:
- 4.3
-
-
Method Details
-
createResponseParser
@Deprecated protected NHttpMessageParser<HttpResponse> createResponseParser(SessionInputBuffer buffer, HttpResponseFactory responseFactory, HttpParams params) Deprecated.(4.3) use constructor.Creates an instance ofNHttpMessageParserto be used by this connection for parsing incomingHttpResponsemessages.This method can be overridden in a super class in order to provide a different implementation of the
NHttpMessageParserinterface.- Returns:
- HTTP response parser.
-
createRequestWriter
@Deprecated protected NHttpMessageWriter<HttpRequest> createRequestWriter(SessionOutputBuffer buffer, HttpParams params) Deprecated.(4.3) use constructor.Creates an instance ofNHttpMessageWriterto be used by this connection for writing out outgoingHttpRequestmessages.This method can be overridden by a super class in order to provide a different implementation of the
NHttpMessageWriterinterface.- Returns:
- HTTP response parser.
-
onResponseReceived
- Since:
- 4.2
-
onRequestSubmitted
- Since:
- 4.2
-
resetInput
public void resetInput()Description copied from interface:NHttpClientConnectionResets input state. This method can be used to prematurely terminate processing of the incoming HTTP response.- Specified by:
resetInputin interfaceNHttpClientConnection
-
resetOutput
public void resetOutput()Description copied from interface:NHttpClientConnectionResets output state. This method can be used to prematurely terminate processing of the outgoing HTTP request.- Specified by:
resetOutputin interfaceNHttpClientConnection
-
consumeInput
-
produceOutput
-
submitRequest
Description copied from interface:NHttpClientConnectionSubmitsHttpRequestto be sent to the target server.- Specified by:
submitRequestin interfaceNHttpClientConnection- Parameters:
request- HTTP request- Throws:
IOException- if I/O error occurs while submitting the requestHttpException- if the HTTP request violates the HTTP protocol.
-
isRequestSubmitted
public boolean isRequestSubmitted()Description copied from interface:NHttpClientConnectionReturnstrueif an HTTP request has been submitted to the target server.- Specified by:
isRequestSubmittedin interfaceNHttpClientConnection- Returns:
trueif an HTTP request has been submitted,falseotherwise.
-
consumeInput
Description copied from interface:NHttpClientIOTargetTriggered when the connection is ready to consume input.- Specified by:
consumeInputin interfaceNHttpClientIOTarget- Parameters:
handler- the client protocol handler.
-
produceOutput
Description copied from interface:NHttpClientIOTargetTriggered when the connection is ready to produce output.- Specified by:
produceOutputin interfaceNHttpClientIOTarget- Parameters:
handler- the client protocol handler.
-
DefaultNHttpClientConnection(IOSession, int, int, ByteBufferAllocator, CharsetDecoder, CharsetEncoder, MessageConstraints, ContentLengthStrategy, ContentLengthStrategy, NHttpMessageWriterFactory, NHttpMessageParserFactory)