com.cometway.httpd
Class ConnectionKMethod

java.lang.Object
  extended by com.cometway.util.KMethod
      extended by com.cometway.httpd.ConnectionKMethod

public class ConnectionKMethod
extends KMethod

This class contains all the code which is needed to deal with an incoming HTTP connection. The WebServer creates this KMethod for each incoming request it receives. NOTES CONCERNING Keep-Alive connections: There are 2 fields in the AgentRequest that pertains to keep-alive connections, KEEP_ALIVE and KEEP_ALIVE_FIELD The KEEP_ALIVE_FIELD property is set by the ConnectionKMethod, if this property is NOT set, a Keep-Alive connection cannot be used The KEEP_ALIVE property is set by the agent that handles the request, if this property is set, the ConnectionKMethod will keep the connection alive The agent that handles the request is responsible for the following: It must return a content-length header in the response, this usually means the agent must return its own HTTP response If a keep alive is allowed, and the client wants a keep-alive, the agent must return the Connection: Keep-Alive field as well as the contents of the KEEP_ALIVE_FIELD property If a keep alive is allowed, and the client wants a keep-alive, the agent must set the KEEP_ALIVE property in the AgentRequest If a keep alive is allowed, and the client wants a keep-alive, the agent must NOT close the Socket or the Socket streams


Field Summary
static java.lang.String KEEP_ALIVE
           
static java.lang.String KEEP_ALIVE_FIELD
           
 
Fields inherited from class com.cometway.util.KMethod
args, debugName, method, obj, print_errors, run, verbose
 
Constructor Summary
ConnectionKMethod(WebServer server, java.net.Socket sock, int linger_time)
          This connection handler requires a reference to the WebServer which created it, the Socket connected to the HTTP client, and the amount of time to linger after the request has been handled before it closes the connection to the client
 
Method Summary
 void execute()
          Everything happens here
protected  void finalize()
           
 java.lang.String getKeepAliveField()
           
protected  java.lang.String getLogDate()
           
protected  java.lang.String readLine(java.io.PushbackInputStream in, int maxLength)
           
protected  java.lang.String socketReadLine(java.io.PushbackInputStream in)
           
 
Methods inherited from class com.cometway.util.KMethod
error, error, print
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEEP_ALIVE

public static final java.lang.String KEEP_ALIVE
See Also:
Constant Field Values

KEEP_ALIVE_FIELD

public static final java.lang.String KEEP_ALIVE_FIELD
See Also:
Constant Field Values
Constructor Detail

ConnectionKMethod

public ConnectionKMethod(WebServer server,
                         java.net.Socket sock,
                         int linger_time)
This connection handler requires a reference to the WebServer which created it, the Socket connected to the HTTP client, and the amount of time to linger after the request has been handled before it closes the connection to the client

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getKeepAliveField

public java.lang.String getKeepAliveField()

readLine

protected java.lang.String readLine(java.io.PushbackInputStream in,
                                    int maxLength)
                             throws java.io.IOException
Throws:
java.io.IOException

socketReadLine

protected java.lang.String socketReadLine(java.io.PushbackInputStream in)
                                   throws java.io.IOException
Throws:
java.io.IOException

execute

public void execute()
Everything happens here

Overrides:
execute in class KMethod

getLogDate

protected java.lang.String getLogDate()