org.apache.http.impl
Class AbstractHttpServerConnection

java.lang.Object
  extended byorg.apache.http.impl.AbstractHttpServerConnection
All Implemented Interfaces:
HttpConnection, HttpServerConnection
Direct Known Subclasses:
SocketHttpServerConnection

public abstract class AbstractHttpServerConnection
extends java.lang.Object
implements HttpServerConnection

Abstract server-side HTTP connection capable of transmitting and receiving data using arbitrary HttpDataReceiver and HttpDataTransmitter

Since:
4.0
Version:
$Revision: 496072 $
Author:
Oleg Kalnichevski

Constructor Summary
AbstractHttpServerConnection()
           
 
Method Summary
protected abstract  void assertOpen()
           
protected  void doFlush()
           
 void flush()
          Sends all pending buffered data over this connection.
 boolean isStale()
          Checks whether this connection has gone down.
 void receiveRequestEntity(HttpEntityEnclosingRequest request)
          Receives the next request entity available from this connection and attaches it to an existing request.
 HttpRequest receiveRequestHeader(HttpParams params)
          Receives the request line and all headers available from this connection.
protected  void receiveRequestHeaders(HttpRequest request)
           
protected  HttpRequest receiveRequestLine(HttpParams params)
           
 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.
protected  void sendResponseHeaders(HttpResponse response)
           
protected  void sendResponseStatusLine(HttpResponse response)
           
protected  void setHttpDataReceiver(HttpDataReceiver datareceiver)
           
protected  void setHttpDataTransmitter(HttpDataTransmitter datatransmitter)
           
protected  void setMaxHeaderCount(int maxHeaderCount)
           
protected  void setRequestFactory(HttpRequestFactory requestfactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.http.HttpConnection
close, getSocketTimeout, isOpen, setSocketTimeout, shutdown
 

Constructor Detail

AbstractHttpServerConnection

public AbstractHttpServerConnection()
Method Detail

assertOpen

protected abstract void assertOpen()
                            throws java.lang.IllegalStateException
Throws:
java.lang.IllegalStateException

setMaxHeaderCount

protected void setMaxHeaderCount(int maxHeaderCount)

setRequestFactory

protected void setRequestFactory(HttpRequestFactory requestfactory)

setHttpDataReceiver

protected void setHttpDataReceiver(HttpDataReceiver datareceiver)

setHttpDataTransmitter

protected void setHttpDataTransmitter(HttpDataTransmitter datatransmitter)

receiveRequestHeader

public HttpRequest receiveRequestHeader(HttpParams params)
                                 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 interface HttpServerConnection
Parameters:
params - the parameters in effect for this connection
Returns:
a new HttpRequest object whose request line and headers are initialized.
Throws:
HttpException
java.io.IOException

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 interface HttpServerConnection
Parameters:
request - the request to attach the entity to.
Throws:
HttpException
java.io.IOException

receiveRequestLine

protected HttpRequest receiveRequestLine(HttpParams params)
                                  throws HttpException,
                                         java.io.IOException
Throws:
HttpException
java.io.IOException

receiveRequestHeaders

protected void receiveRequestHeaders(HttpRequest request)
                              throws HttpException,
                                     java.io.IOException
Throws:
HttpException
java.io.IOException

doFlush

protected void doFlush()
                throws java.io.IOException
Throws:
java.io.IOException

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 interface HttpServerConnection
Throws:
java.io.IOException

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 interface HttpServerConnection
Parameters:
response - the response whose headers to send.
Throws:
java.io.IOException
HttpException

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 interface HttpServerConnection
Parameters:
response - the response whose entity to send.
Throws:
java.io.IOException
HttpException

sendResponseStatusLine

protected void sendResponseStatusLine(HttpResponse response)
                               throws HttpException,
                                      java.io.IOException
Throws:
HttpException
java.io.IOException

sendResponseHeaders

protected void sendResponseHeaders(HttpResponse response)
                            throws HttpException,
                                   java.io.IOException
Throws:
HttpException
java.io.IOException

isStale

public boolean isStale()
Description copied from interface: HttpConnection
Checks whether this connection has gone down. Network connections may get closed during some time of inactivity for several reasons. The next time a read is attempted on such a connection it will throw an IOException. This method tries to alleviate this inconvenience by trying to find out if a connection is still usable. Implementations may do that by attempting a read with a very small timeout. Thus this method may block for a small amount of time before returning a result. It is therefore an expensive operation.

Specified by:
isStale in interface HttpConnection
Returns:
true if attempts to use this connection are likely to succeed, or false if they are likely to fail and this connection should be closed


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.