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:
java.io.Closeable
,java.lang.AutoCloseable
,HttpConnection
,HttpInetConnection
,IOControl
,NHttpClientConnection
,NHttpClientIOTarget
,NHttpConnection
,SessionBufferStatus
,SocketAccessor
public class DefaultNHttpClientConnection extends NHttpConnectionBase implements NHttpClientIOTarget
Default implementation of theNHttpClientConnection
interface.- Since:
- 4.0
-
-
Field Summary
-
Fields inherited from interface org.apache.http.nio.NHttpConnection
ACTIVE, CLOSED, CLOSING
-
-
Constructor Summary
Constructors Constructor Description DefaultNHttpClientConnection(IOSession session, int buffersize)
DefaultNHttpClientConnection(IOSession session, int buffersize, int fragmentSizeHint, ByteBufferAllocator allocator, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.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, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints)
DefaultNHttpClientConnection(IOSession session, HttpResponseFactory responseFactory, ByteBufferAllocator allocator, HttpParams params)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consumeInput(NHttpClientEventHandler handler)
void
consumeInput(NHttpClientHandler handler)
Triggered when the connection is ready to consume input.boolean
isRequestSubmitted()
Returnstrue
if an HTTP request has been submitted to the target server.void
produceOutput(NHttpClientEventHandler handler)
void
produceOutput(NHttpClientHandler handler)
Triggered when the connection is ready to produce output.void
resetInput()
Resets input state.void
resetOutput()
Resets output state.void
submitRequest(HttpRequest request)
SubmitsHttpRequest
to be sent to the target server.-
Methods inherited from class org.apache.http.impl.nio.NHttpConnectionBase
close, getContext, getHttpRequest, getHttpResponse, getLocalAddress, getLocalPort, getMetrics, getRemoteAddress, getRemotePort, getSocket, getSocketTimeout, getStatus, hasBufferedInput, hasBufferedOutput, isOpen, isStale, requestInput, requestOutput, setSocketTimeout, shutdown, suspendInput, suspendOutput, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.http.HttpConnection
close, getMetrics, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown
-
Methods inherited from interface org.apache.http.nio.IOControl
requestInput, requestOutput, shutdown, suspendInput, suspendOutput
-
Methods inherited from interface org.apache.http.nio.NHttpConnection
getContext, getHttpRequest, getHttpResponse, getStatus
-
-
-
-
Constructor Detail
-
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, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.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. Ifnull
HeapByteBufferAllocator.INSTANCE
will be used.chardecoder
- decoder to be used for decoding HTTP protocol elements. Ifnull
simple type cast will be used for byte to char conversion.charencoder
- encoder to be used for encoding HTTP protocol elements. Ifnull
simple type cast will be used for char to byte conversion.constraints
- Message constraints. Ifnull
MessageConstraints.DEFAULT
will be used.incomingContentStrategy
- incoming content length strategy. Ifnull
LaxContentLengthStrategy.INSTANCE
will be used.outgoingContentStrategy
- outgoing content length strategy. Ifnull
StrictContentLengthStrategy.INSTANCE
will be used.- Since:
- 4.3
-
DefaultNHttpClientConnection
public DefaultNHttpClientConnection(IOSession session, int buffersize, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints)
- Since:
- 4.3
-
DefaultNHttpClientConnection
public DefaultNHttpClientConnection(IOSession session, int buffersize)
- Since:
- 4.3
-
-
Method Detail
-
resetInput
public void resetInput()
Description copied from interface:NHttpClientConnection
Resets input state. This method can be used to prematurely terminate processing of the incoming HTTP response.- Specified by:
resetInput
in interfaceNHttpClientConnection
-
resetOutput
public void resetOutput()
Description copied from interface:NHttpClientConnection
Resets output state. This method can be used to prematurely terminate processing of the outgoing HTTP request.- Specified by:
resetOutput
in interfaceNHttpClientConnection
-
consumeInput
public void consumeInput(NHttpClientEventHandler handler)
-
produceOutput
public void produceOutput(NHttpClientEventHandler handler)
-
submitRequest
public void submitRequest(HttpRequest request) throws java.io.IOException, HttpException
Description copied from interface:NHttpClientConnection
SubmitsHttpRequest
to be sent to the target server.- Specified by:
submitRequest
in interfaceNHttpClientConnection
- Parameters:
request
- HTTP request- Throws:
java.io.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:NHttpClientConnection
Returnstrue
if an HTTP request has been submitted to the target server.- Specified by:
isRequestSubmitted
in interfaceNHttpClientConnection
- Returns:
true
if an HTTP request has been submitted,false
otherwise.
-
consumeInput
public void consumeInput(NHttpClientHandler handler)
Description copied from interface:NHttpClientIOTarget
Triggered when the connection is ready to consume input.- Specified by:
consumeInput
in interfaceNHttpClientIOTarget
- Parameters:
handler
- the client protocol handler.
-
produceOutput
public void produceOutput(NHttpClientHandler handler)
Description copied from interface:NHttpClientIOTarget
Triggered when the connection is ready to produce output.- Specified by:
produceOutput
in interfaceNHttpClientIOTarget
- Parameters:
handler
- the client protocol handler.
-
-