com.cometway.httpd
Class ConnectionKMethod
java.lang.Object
com.cometway.util.KMethod
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
|
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 |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
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
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()