|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object
|
+--java.lang.Thread
|
+--RestartableThread
|
+--Connection
This is the class that handles one connection And makes sure the content is delivered to the client. It reads the request and get the data, and filters it and sends the data to the client. If Keepalive is suitable it reads the next request.
| Field Summary | |
static int |
READ_BUFFER_SIZE
|
java.net.Socket |
socket
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
Connection()
Create a new Connection. |
|
| Method Summary | |
protected void |
closeDown()
Close down nicely. |
void |
doRun()
Does run the thread: called by RestartableThread.run() |
static HTTPHeader |
getHeader(java.lang.String statusLine)
Get a new HTTPHeader initialized with some data. |
boolean |
getKeepalive()
Get the keepalive value. |
void |
handleRequest(HTTPHeader header)
Handle a request by getting the datastream (from the cache or the web). |
protected boolean |
openStreams()
Set up the streams used for reading request and sending data to and from the client. |
protected boolean |
readBody(HTTPHeader header)
If a content-length header field has been found, we have to read content-length 's value bytes and forward them to the server |
protected void |
send(HTTPHeader header)
Send a header to the client. |
void |
send400(java.lang.String message)
Send a 400 Bad Request error to the client. |
void |
send403(java.lang.String message)
Send a 403 Forbidden error to the client. |
void |
send500(java.lang.Throwable exception)
Send a 500 Internal Server Error header for the given exception. |
void |
setKeepalive(boolean keepalive)
Set keepalive to a new value. |
void |
setSocket(java.net.Socket socket)
Give this connection a socket to handle, this makes call to start() method |
| Methods inherited from class RestartableThread |
run, start |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static int READ_BUFFER_SIZE
public java.net.Socket socket
| Constructor Detail |
public Connection()
| Method Detail |
public void setSocket(java.net.Socket socket)
socket - the Socket that is requesting service.protected void closeDown()
public void doRun()
doRun in class RestartableThreadprotected boolean openStreams()
protected boolean readBody(HTTPHeader header)
protected void send(HTTPHeader header)
header - the HTTPHeader to send.public void handleRequest(HTTPHeader header)
header - the request made.public void setKeepalive(boolean keepalive)
keepalive - the new keepalive value.public boolean getKeepalive()
public static HTTPHeader getHeader(java.lang.String statusLine)
statusline - the statusline of the response.public void send403(java.lang.String message)
message - additional message to tell the client.public void send400(java.lang.String message)
message - additional message to tell the client.public void send500(java.lang.Throwable exception)
exception - the Exception made.
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||