seda.sandStorm.lib.http
Class httpConnection

java.lang.Object
  extended byseda.sandStorm.core.SimpleSink
      extended byseda.sandStorm.lib.http.httpConnection
All Implemented Interfaces:
httpConst, ProfilableIF, QueueElementIF, SinkIF

public class httpConnection
extends SimpleSink
implements httpConst, QueueElementIF

This class represents a single HTTP connection. When an httpServer receives a connection, an httpConnection is pushed to the user. To send HTTP responses to a client, you can enqueue an httpResponse object on the corresponding httpConnection.

Author:
Matt Welsh
See Also:
httpRequest, httpResponse

Field Summary
 java.lang.Object userTag
          Can be used by applications to associate an arbitrary data object with this connection.
 
Fields inherited from interface seda.sandStorm.lib.http.httpConst
CRLF, DEFAULT_HTTP_PORT, HTTP_VERSION, WRITE_CLOG_THRESHOLD
 
Constructor Summary
(package private) httpConnection(ATcpConnection tcpconn, httpServer hs, SinkIF compQ)
          Package-internal: Create an httpConnection with the given TCP connection and completion queue.
 
Method Summary
 void close(SinkIF compQ)
          Close the connection.
 void enqueue_abort(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 void enqueue_commit(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 boolean enqueue_lossy(QueueElementIF element)
          Enqueue outgoing data on this connection.
 void enqueue_many(QueueElementIF[] elements)
          Enqueue outgoing data on this connection.
 java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
          Not supported; throws an IllegalArgumentException.
 void enqueue(QueueElementIF element)
          Enqueue outgoing data on this connection.
 void flush(SinkIF compQ)
          Flush the connection; a SinkFlushedEvent will be pushed to the user when all packets have drained.
 ATcpConnection getConnection()
          Return the ATcpConnection associated with this connection.
(package private)  void parsePacket(ATcpInPacket pkt)
          Package-internal: Parse the data contained in the given TCP packet.
 int size()
          Return the number of outgoing packets waiting to be sent.
 java.lang.String toString()
           
 
Methods inherited from class seda.sandStorm.core.SimpleSink
getEnqueuePredicate, profileSize, setEnqueuePredicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

userTag

public java.lang.Object userTag
Can be used by applications to associate an arbitrary data object with this connection.

Constructor Detail

httpConnection

httpConnection(ATcpConnection tcpconn,
               httpServer hs,
               SinkIF compQ)
Package-internal: Create an httpConnection with the given TCP connection and completion queue.

Method Detail

parsePacket

void parsePacket(ATcpInPacket pkt)
           throws java.io.IOException
Package-internal: Parse the data contained in the given TCP packet.

Throws:
java.io.IOException

getConnection

public ATcpConnection getConnection()
Return the ATcpConnection associated with this connection.


toString

public java.lang.String toString()

enqueue

public void enqueue(QueueElementIF element)
             throws SinkException
Enqueue outgoing data on this connection. The 'element' must be of type httpResponder.

Specified by:
enqueue in interface SinkIF
Specified by:
enqueue in class SimpleSink
Throws:
SinkException

enqueue_lossy

public boolean enqueue_lossy(QueueElementIF element)
Enqueue outgoing data on this connection. The 'element' must be of type httpResponder.

Specified by:
enqueue_lossy in interface SinkIF
Overrides:
enqueue_lossy in class SimpleSink

enqueue_many

public void enqueue_many(QueueElementIF[] elements)
                  throws SinkException
Enqueue outgoing data on this connection. Each item in the elements array must be of type httpResponse.

Specified by:
enqueue_many in interface SinkIF
Overrides:
enqueue_many in class SimpleSink
Throws:
SinkException

size

public int size()
Return the number of outgoing packets waiting to be sent.

Specified by:
size in interface SinkIF
Overrides:
size in class SimpleSink

close

public void close(SinkIF compQ)
           throws SinkClosedException
Close the connection.

Throws:
SinkClosedException

flush

public void flush(SinkIF compQ)
           throws SinkClosedException
Flush the connection; a SinkFlushedEvent will be pushed to the user when all packets have drained.

Throws:
SinkClosedException

enqueue_prepare

public java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
                                 throws SinkException
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_prepare in interface SinkIF
Overrides:
enqueue_prepare in class SimpleSink
Throws:
SinkException

enqueue_commit

public void enqueue_commit(java.lang.Object key)
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_commit in interface SinkIF
Overrides:
enqueue_commit in class SimpleSink

enqueue_abort

public void enqueue_abort(java.lang.Object key)
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.

Specified by:
enqueue_abort in interface SinkIF
Overrides:
enqueue_abort in class SimpleSink