Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.http.impl
Class DefaultHttpServerConnection  view DefaultHttpServerConnection download DefaultHttpServerConnection.java

java.lang.Object
  extended byorg.apache.http.impl.AbstractHttpConnection
      extended byorg.apache.http.impl.DefaultHttpServerConnection
All Implemented Interfaces:
org.apache.http.HttpConnection, org.apache.http.HttpServerConnection

public class DefaultHttpServerConnection
extends AbstractHttpConnection
implements org.apache.http.HttpServerConnection

Default implementation of a server-side HTTP connection.

Since:
4.0
Version:
$Revision: 411100 $

Field Summary
private  org.apache.http.io.CharArrayBuffer buffer
           
protected  org.apache.http.io.HttpDataReceiver datareceiver
           
protected  org.apache.http.io.HttpDataTransmitter datatransmitter
           
private  org.apache.http.entity.EntityDeserializer entitydeserializer
           
private  org.apache.http.entity.EntitySerializer entityserializer
           
private  int maxHeaderCount
           
protected  boolean open
           
private  org.apache.http.HttpRequestFactory requestfactory
           
protected  java.net.Socket socket
           
 
Constructor Summary
DefaultHttpServerConnection()
           
 
Method Summary
protected  void assertNotOpen()
           
protected  void assertOpen()
           
 void bind(java.net.Socket socket, org.apache.http.params.HttpParams params)
          Binds this connection to an underlying socket.
 void close()
          This method will gracefully close the connection.
 void flush()
          Sends all pending buffered data over this connection.
 boolean isOpen()
          Checks if this connection is open.
 boolean isStale()
          Network connections may get closed during some time of inactivity for several reasons.
 void receiveRequestEntity(org.apache.http.HttpEntityEnclosingRequest request)
          Receives the next request entity available from this connection and attaches it to an existing request.
 org.apache.http.HttpRequest receiveRequestHeader(org.apache.http.params.HttpParams params)
          Receives the request line and all headers available from this connection.
protected  void receiveRequestHeaders(org.apache.http.HttpRequest request)
           
protected  org.apache.http.HttpRequest receiveRequestLine(org.apache.http.params.HttpParams params)
           
 void sendResponseEntity(org.apache.http.HttpResponse response)
          Sends the response entity of a response over this connection.
 void sendResponseHeader(org.apache.http.HttpResponse response)
          Sends the response line and headers of a response over this connection.
protected  void sendResponseHeaders(org.apache.http.HttpResponse response)
           
protected  void sendResponseStatusLine(org.apache.http.HttpResponse response)
           
 void setEntityDeserializer(org.apache.http.entity.EntityDeserializer entitydeserializer)
           
 void setEntitySerializer(org.apache.http.entity.EntitySerializer entityserializer)
           
 void setReceiverFactory(org.apache.http.io.HttpDataReceiverFactory rcvfactory)
           
 void setRequestFactory(org.apache.http.HttpRequestFactory requestfactory)
           
 void setTransmitterFactory(org.apache.http.io.HttpDataTransmitterFactory trxfactory)
           
 void shutdown()
          This method will force close the connection.
 
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, isOpen, isStale, shutdown
 

Field Detail

maxHeaderCount

private int maxHeaderCount

buffer

private final org.apache.http.io.CharArrayBuffer buffer

requestfactory

private org.apache.http.HttpRequestFactory requestfactory

entityserializer

private org.apache.http.entity.EntitySerializer entityserializer

entitydeserializer

private org.apache.http.entity.EntityDeserializer entitydeserializer

open

protected volatile boolean open

socket

protected java.net.Socket socket

datatransmitter

protected org.apache.http.io.HttpDataTransmitter datatransmitter

datareceiver

protected org.apache.http.io.HttpDataReceiver datareceiver
Constructor Detail

DefaultHttpServerConnection

public DefaultHttpServerConnection()
Method Detail

setRequestFactory

public void setRequestFactory(org.apache.http.HttpRequestFactory requestfactory)

setEntityDeserializer

public void setEntityDeserializer(org.apache.http.entity.EntityDeserializer entitydeserializer)

setEntitySerializer

public void setEntitySerializer(org.apache.http.entity.EntitySerializer entityserializer)

bind

public void bind(java.net.Socket socket,
                 org.apache.http.params.HttpParams params)
          throws java.io.IOException
Description copied from interface: org.apache.http.HttpServerConnection
Binds this connection to an underlying socket.

Specified by:
bind in interface org.apache.http.HttpServerConnection
Overrides:
bind in class AbstractHttpConnection

receiveRequestHeader

public org.apache.http.HttpRequest receiveRequestHeader(org.apache.http.params.HttpParams params)
                                                 throws org.apache.http.HttpException,
                                                        java.io.IOException
Description copied from interface: org.apache.http.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 org.apache.http.HttpServerConnection

receiveRequestEntity

public void receiveRequestEntity(org.apache.http.HttpEntityEnclosingRequest request)
                          throws org.apache.http.HttpException,
                                 java.io.IOException
Description copied from interface: org.apache.http.HttpServerConnection
Receives the next request entity available from this connection and attaches it to an existing request.

Specified by:
receiveRequestEntity in interface org.apache.http.HttpServerConnection

receiveRequestLine

protected org.apache.http.HttpRequest receiveRequestLine(org.apache.http.params.HttpParams params)
                                                  throws org.apache.http.HttpException,
                                                         java.io.IOException

receiveRequestHeaders

protected void receiveRequestHeaders(org.apache.http.HttpRequest request)
                              throws org.apache.http.HttpException,
                                     java.io.IOException

flush

public void flush()
           throws java.io.IOException
Description copied from interface: org.apache.http.HttpServerConnection
Sends all pending buffered data over this connection.

Specified by:
flush in interface org.apache.http.HttpServerConnection

sendResponseHeader

public void sendResponseHeader(org.apache.http.HttpResponse response)
                        throws org.apache.http.HttpException,
                               java.io.IOException
Description copied from interface: org.apache.http.HttpServerConnection
Sends the response line and headers of a response over this connection.

Specified by:
sendResponseHeader in interface org.apache.http.HttpServerConnection

sendResponseEntity

public void sendResponseEntity(org.apache.http.HttpResponse response)
                        throws org.apache.http.HttpException,
                               java.io.IOException
Description copied from interface: org.apache.http.HttpServerConnection
Sends the response entity of a response over this connection.

Specified by:
sendResponseEntity in interface org.apache.http.HttpServerConnection

sendResponseStatusLine

protected void sendResponseStatusLine(org.apache.http.HttpResponse response)
                               throws org.apache.http.HttpException,
                                      java.io.IOException

sendResponseHeaders

protected void sendResponseHeaders(org.apache.http.HttpResponse response)
                            throws org.apache.http.HttpException,
                                   java.io.IOException

setReceiverFactory

public void setReceiverFactory(org.apache.http.io.HttpDataReceiverFactory rcvfactory)

setTransmitterFactory

public void setTransmitterFactory(org.apache.http.io.HttpDataTransmitterFactory trxfactory)

assertNotOpen

protected void assertNotOpen()

assertOpen

protected void assertOpen()

isOpen

public boolean isOpen()
Description copied from interface: org.apache.http.HttpConnection
Checks if this connection is open.

Specified by:
isOpen in interface org.apache.http.HttpConnection

shutdown

public void shutdown()
              throws java.io.IOException
Description copied from interface: org.apache.http.HttpConnection
This method will force close the connection. This is the only method, which may be called from a different thread to terminate the connection. This method will not attempt to flush the transmitter's internal buffer prior to closing the underlying socket.

Specified by:
shutdown in interface org.apache.http.HttpConnection

close

public void close()
           throws java.io.IOException
Description copied from interface: org.apache.http.HttpConnection
This method will gracefully close the connection. It will attempt to flush the transmitter's internal buffer prior to closing the underlying socket. This method MAY NOT be called from a different thread to force shutdown the connection. Use #shutdown() instead.

Specified by:
close in interface org.apache.http.HttpConnection

isStale

public boolean isStale()
Description copied from interface: org.apache.http.HttpConnection
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 indefinite time before returning a result.

Specified by:
isStale in interface org.apache.http.HttpConnection