|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object JWSWorker
class JWSWorker
A worker thread's data and run() method. JWSWorker is not an actual thread in and of itself. The thread pool is what maintains the threads for us. JWSWorker is just a Runnable class that the thread pool will assign a thread to. That thread will execute the JWSWorker object's run() method. Which will then process the HTTP request coming in on the socket. When the JWSWorker's run() method finishes, the thread pool will assign the thread to another JWSWorker object. Which will process another HTTP request. And so on.
Field Summary | |
---|---|
private java.net.Socket |
clientSock
|
static java.net.FileNameMap |
mimeData
|
Constructor Summary | |
---|---|
private |
JWSWorker()
Don't use this constructor. |
|
JWSWorker(java.net.Socket s)
Create a JWSWorker object with a socket to operate on. |
Method Summary | |
---|---|
private void |
handleConnection(java.net.Socket clientSock)
Reads in an HTTP request from the given Socket and sends
the appropriate reply. |
void |
run()
run() is just a wrapper for handleConnection(). |
static void |
sendErrorAndClose(java.net.Socket sock,
java.io.OutputStream sockOut,
java.lang.String error)
Sends an error message and closes the connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.net.FileNameMap mimeData
private java.net.Socket clientSock
Constructor Detail |
---|
private JWSWorker()
public JWSWorker(java.net.Socket s)
s
- A connected socket to read the HTTP request from,
and send the resulting data/error message back to.Socket
Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
private void handleConnection(java.net.Socket clientSock)
Socket
and sends
the appropriate reply. The request method and request URI are parsed
out of the HTTP request and the corresponding file contents are sent,
or an appropriate error code. Finally, the socket is closed.
BUGS: No security checking of the URI is performed, i.e. a malicious user could request "/../../../etc/passwd" and get it.
clientSock
- A connected socket to read the HTTP request from,
and send the resulting data/error message back to.Socket
public static void sendErrorAndClose(java.net.Socket sock, java.io.OutputStream sockOut, java.lang.String error)
sock
- The socket to send the error to and close.sockOut
- The socket's output stream. Method creates if null.error
- A string that contains the error message.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |