public static class HttpServer.RequestHandler
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CRLF
crlf
|
static char |
LF
_more_
|
protected HttpServer |
server
Back reference to server
|
Constructor and Description |
---|
RequestHandler(HttpServer server,
java.net.Socket socket)
Ctor
|
Modifier and Type | Method and Description |
---|---|
protected void |
addArg(java.util.Hashtable args,
java.lang.String name,
java.lang.String value) |
java.io.OutputStream |
getOutputStream()
_more_
|
java.net.Socket |
getSocket()
_more_
|
protected void |
handleFileUpload(java.lang.String attrName,
java.lang.String filename,
java.util.Hashtable props,
java.util.Hashtable args,
org.apache.commons.fileupload.MultipartStream multipartStream)
_more_
|
protected void |
handleRequest(java.lang.String path,
java.util.Hashtable formArgs,
java.util.Hashtable httpArgs,
java.lang.String content)
Handle the request.
|
protected void |
log(java.lang.String msg)
_more_
|
protected boolean |
okToParseContent(java.lang.String path,
java.lang.String contentString,
java.util.Hashtable httpArgs)
_more_
|
protected void |
parseArgs(java.lang.String args,
java.util.Hashtable ht)
Utility to parse name=value& args
|
void |
redirect(java.lang.String url)
_more_
|
void |
run()
Run the read
|
protected void |
writeBytes(java.io.InputStream fis,
java.lang.String type,
long length)
Transfer bytes
|
protected void |
writeHeader(int code,
long length,
java.lang.String type)
_more_
|
protected void |
writeHeaderArgs()
_more_
|
void |
writeHtml(java.lang.StringBuffer content)
_more_
|
protected void |
writeLine(java.lang.String line)
Write the line to the output
|
void |
writeResult(boolean ok,
byte[] content,
java.lang.String type)
_more_
|
void |
writeResult(boolean ok,
java.lang.StringBuffer content,
java.lang.String type)
_more_
|
void |
writeResult(boolean ok,
java.lang.String content,
java.lang.String type)
Write header and content
|
void |
writeResult(int code,
byte[] content,
java.lang.String type)
_more_
|
void |
writeResult(int code,
java.io.InputStream inputStream,
java.lang.String type)
_more_
|
void |
writeResult(int code,
java.lang.StringBuffer content,
java.lang.String type)
_more_
|
void |
writeResult(int code,
java.lang.String content,
java.lang.String type)
_more_
|
void |
writeXml(java.lang.StringBuffer content)
_more_
|
public static final java.lang.String CRLF
public static final char LF
protected HttpServer server
public RequestHandler(HttpServer server, java.net.Socket socket) throws java.lang.Exception
server
- The serversocket
- The socketjava.lang.Exception
- On badnesspublic java.net.Socket getSocket()
public java.io.OutputStream getOutputStream()
public void run()
run
in interface java.lang.Runnable
protected void log(java.lang.String msg)
msg
- _more_protected void addArg(java.util.Hashtable args, java.lang.String name, java.lang.String value)
protected void handleFileUpload(java.lang.String attrName, java.lang.String filename, java.util.Hashtable props, java.util.Hashtable args, org.apache.commons.fileupload.MultipartStream multipartStream) throws java.lang.Exception
attrName
- _more_filename
- _more_props
- _more_args
- _more_multipartStream
- _more_java.lang.Exception
- _more_protected boolean okToParseContent(java.lang.String path, java.lang.String contentString, java.util.Hashtable httpArgs)
path
- _more_contentString
- _more_httpArgs
- _more_protected void parseArgs(java.lang.String args, java.util.Hashtable ht)
args
- Argsht
- Table to put args inprotected void handleRequest(java.lang.String path, java.util.Hashtable formArgs, java.util.Hashtable httpArgs, java.lang.String content) throws java.lang.Exception
path
- Url pathformArgs
- get or post argshttpArgs
- http headerscontent
- _more_java.lang.Exception
- On badnessprotected void writeLine(java.lang.String line) throws java.lang.Exception
line
- Line of textjava.lang.Exception
- On badnesspublic void writeResult(boolean ok, java.lang.String content, java.lang.String type) throws java.lang.Exception
ok
- Was okcontent
- The content to writetype
- Type of contentjava.lang.Exception
- On badnesspublic void writeResult(int code, java.lang.String content, java.lang.String type) throws java.lang.Exception
code
- _more_content
- _more_type
- _more_java.lang.Exception
- _more_public void writeResult(boolean ok, java.lang.StringBuffer content, java.lang.String type) throws java.lang.Exception
ok
- _more_content
- _more_type
- _more_java.lang.Exception
- _more_public void writeResult(int code, java.lang.StringBuffer content, java.lang.String type) throws java.lang.Exception
code
- _more_content
- _more_type
- _more_java.lang.Exception
- _more_public void writeXml(java.lang.StringBuffer content) throws java.lang.Exception
content
- _more_java.lang.Exception
- _more_public void writeHtml(java.lang.StringBuffer content) throws java.lang.Exception
content
- _more_java.lang.Exception
- _more_public void writeResult(boolean ok, byte[] content, java.lang.String type) throws java.lang.Exception
ok
- _more_content
- _more_type
- _more_java.lang.Exception
- On badnesspublic void writeResult(int code, byte[] content, java.lang.String type) throws java.lang.Exception
code
- _more_content
- _more_type
- _more_java.lang.Exception
- _more_public void writeResult(int code, java.io.InputStream inputStream, java.lang.String type) throws java.lang.Exception
code
- _more_inputStream
- _more_type
- _more_java.lang.Exception
- _more_protected void writeHeader(int code, long length, java.lang.String type) throws java.lang.Exception
code
- return codelength
- _more_type
- _more_java.lang.Exception
- On badnesspublic void redirect(java.lang.String url) throws java.lang.Exception
url
- _more_java.lang.Exception
- _more_protected void writeHeaderArgs() throws java.lang.Exception
java.lang.Exception
- _more_protected void writeBytes(java.io.InputStream fis, java.lang.String type, long length) throws java.lang.Exception
fis
- input streamtype
- _more_length
- _more_java.lang.Exception
- On badness