Package org.apache.http.impl
Class DefaultBHttpServerConnection
- java.lang.Object
-
- org.apache.http.impl.BHttpConnectionBase
-
- org.apache.http.impl.DefaultBHttpServerConnection
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,HttpConnection
,HttpInetConnection
,HttpServerConnection
public class DefaultBHttpServerConnection extends BHttpConnectionBase implements HttpServerConnection
Default implementation ofHttpServerConnection
.- Since:
- 4.3
-
-
Constructor Summary
Constructors Constructor Description DefaultBHttpServerConnection(int buffersize)
DefaultBHttpServerConnection(int buffersize, int fragmentSizeHint, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, HttpMessageParserFactory<HttpRequest> requestParserFactory, HttpMessageWriterFactory<HttpResponse> responseWriterFactory)
Creates new instance of DefaultBHttpServerConnection.DefaultBHttpServerConnection(int buffersize, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
bind(java.net.Socket socket)
void
flush()
Sends all pending buffered data over this connection.void
receiveRequestEntity(HttpEntityEnclosingRequest request)
Receives the next request entity available from this connection and attaches it to an existing request.HttpRequest
receiveRequestHeader()
Receives the request line and all headers available from this connection.void
sendResponseEntity(HttpResponse response)
Sends the response entity of a response over this connection.void
sendResponseHeader(HttpResponse response)
Sends the response line and headers of a response over this connection.-
Methods inherited from class org.apache.http.impl.BHttpConnectionBase
close, getLocalAddress, getLocalPort, getMetrics, getRemoteAddress, getRemotePort, getSocketTimeout, isOpen, isStale, setSocketTimeout, shutdown, 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
-
-
-
-
Constructor Detail
-
DefaultBHttpServerConnection
public DefaultBHttpServerConnection(int buffersize, int fragmentSizeHint, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints, ContentLengthStrategy incomingContentStrategy, ContentLengthStrategy outgoingContentStrategy, HttpMessageParserFactory<HttpRequest> requestParserFactory, HttpMessageWriterFactory<HttpResponse> responseWriterFactory)
Creates new instance of DefaultBHttpServerConnection.- Parameters:
buffersize
- buffer size. Must be a positive number.fragmentSizeHint
- fragment size hint.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
DisallowIdentityContentLengthStrategy.INSTANCE
will be used.outgoingContentStrategy
- outgoing content length strategy. Ifnull
StrictContentLengthStrategy.INSTANCE
will be used.requestParserFactory
- request parser factory. Ifnull
DefaultHttpRequestParserFactory.INSTANCE
will be used.responseWriterFactory
- response writer factory. Ifnull
DefaultHttpResponseWriterFactory.INSTANCE
will be used.
-
DefaultBHttpServerConnection
public DefaultBHttpServerConnection(int buffersize, java.nio.charset.CharsetDecoder chardecoder, java.nio.charset.CharsetEncoder charencoder, MessageConstraints constraints)
-
DefaultBHttpServerConnection
public DefaultBHttpServerConnection(int buffersize)
-
-
Method Detail
-
bind
public void bind(java.net.Socket socket) throws java.io.IOException
- Throws:
java.io.IOException
-
receiveRequestHeader
public HttpRequest receiveRequestHeader() throws HttpException, java.io.IOException
Description copied from interface:HttpServerConnection
Receives the request line and all headers available from this connection. The caller should examine the returned request and decide if to receive a request entity as well.- Specified by:
receiveRequestHeader
in interfaceHttpServerConnection
- Returns:
- a new HttpRequest object whose request line and headers are initialized.
- Throws:
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O error
-
receiveRequestEntity
public void receiveRequestEntity(HttpEntityEnclosingRequest request) throws HttpException, java.io.IOException
Description copied from interface:HttpServerConnection
Receives the next request entity available from this connection and attaches it to an existing request.- Specified by:
receiveRequestEntity
in interfaceHttpServerConnection
- Parameters:
request
- the request to attach the entity to.- Throws:
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O error
-
sendResponseHeader
public void sendResponseHeader(HttpResponse response) throws HttpException, java.io.IOException
Description copied from interface:HttpServerConnection
Sends the response line and headers of a response over this connection.- Specified by:
sendResponseHeader
in interfaceHttpServerConnection
- Parameters:
response
- the response whose headers to send.- Throws:
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O error
-
sendResponseEntity
public void sendResponseEntity(HttpResponse response) throws HttpException, java.io.IOException
Description copied from interface:HttpServerConnection
Sends the response entity of a response over this connection.- Specified by:
sendResponseEntity
in interfaceHttpServerConnection
- Parameters:
response
- the response whose entity to send.- Throws:
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O error
-
flush
public void flush() throws java.io.IOException
Description copied from interface:HttpServerConnection
Sends all pending buffered data over this connection.- Specified by:
flush
in interfaceHttpServerConnection
- Throws:
java.io.IOException
- in case of an I/O error
-
-