ucar.unidata.util
Class HttpServer.RequestHandler

java.lang.Object
  extended by ucar.unidata.util.HttpServer.RequestHandler
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
IdvMonitor.MonitorRequestHandler, ImageServer.ImageRequestHandler, OneInstanceServer.OneInstanceRequestHandler
Enclosing class:
HttpServer

public static class HttpServer.RequestHandler
extends Object
implements Runnable

Class RequestHandler handles requests

Version:
$Revision: 1.12 $
Author:
IDV Development Team

Field Summary
static String CRLF
          crlf
static char LF
          _more_
protected  HttpServer server
          Back reference to server
 
Constructor Summary
HttpServer.RequestHandler(HttpServer server, Socket socket)
          Ctor
 
Method Summary
protected  void addArg(Hashtable args, String name, String value)
           
 OutputStream getOutputStream()
          _more_
 Socket getSocket()
          _more_
protected  void handleFileUpload(String attrName, String filename, Hashtable props, Hashtable args, org.apache.commons.fileupload.MultipartStream multipartStream)
          _more_
protected  void handleRequest(String path, Hashtable formArgs, Hashtable httpArgs, String content)
          Handle the request.
protected  void log(String msg)
          _more_
protected  boolean okToParseContent(String path, String contentString, Hashtable httpArgs)
          _more_
protected  void parseArgs(String args, Hashtable ht)
          Utility to parse name=value& args
 void redirect(String url)
          _more_
 void run()
          Run the read
protected  void writeBytes(InputStream fis, String type, long length)
          Transfer bytes
protected  void writeHeader(int code, long length, String type)
          _more_
protected  void writeHeaderArgs()
          _more_
 void writeHtml(StringBuffer content)
          _more_
protected  void writeLine(String line)
          Write the line to the output
 void writeResult(boolean ok, byte[] content, String type)
          _more_
 void writeResult(boolean ok, StringBuffer content, String type)
          _more_
 void writeResult(boolean ok, String content, String type)
          Write header and content
 void writeResult(int code, byte[] content, String type)
          _more_
 void writeResult(int code, InputStream inputStream, String type)
          _more_
 void writeResult(int code, StringBuffer content, String type)
          _more_
 void writeResult(int code, String content, String type)
          _more_
 void writeXml(StringBuffer content)
          _more_
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CRLF

public static final String CRLF
crlf

See Also:
Constant Field Values

LF

public static final char LF
_more_

See Also:
Constant Field Values

server

protected HttpServer server
Back reference to server

Constructor Detail

HttpServer.RequestHandler

public HttpServer.RequestHandler(HttpServer server,
                                 Socket socket)
                          throws Exception
Ctor

Parameters:
server - The server
socket - The socket
Throws:
Exception - On badness
Method Detail

getSocket

public Socket getSocket()
_more_

Returns:
_more_

getOutputStream

public OutputStream getOutputStream()
_more_

Returns:
_more_

run

public void run()
Run the read

Specified by:
run in interface Runnable

log

protected void log(String msg)
_more_

Parameters:
msg - _more_

addArg

protected void addArg(Hashtable args,
                      String name,
                      String value)

handleFileUpload

protected void handleFileUpload(String attrName,
                                String filename,
                                Hashtable props,
                                Hashtable args,
                                org.apache.commons.fileupload.MultipartStream multipartStream)
                         throws Exception
_more_

Parameters:
attrName - _more_
filename - _more_
props - _more_
args - _more_
multipartStream - _more_
Throws:
Exception - _more_

okToParseContent

protected boolean okToParseContent(String path,
                                   String contentString,
                                   Hashtable httpArgs)
_more_

Parameters:
path - _more_
contentString - _more_
httpArgs - _more_
Returns:
_more_

parseArgs

protected void parseArgs(String args,
                         Hashtable ht)
Utility to parse name=value& args

Parameters:
args - Args
ht - Table to put args in

handleRequest

protected void handleRequest(String path,
                             Hashtable formArgs,
                             Hashtable httpArgs,
                             String content)
                      throws Exception
Handle the request.

Parameters:
path - Url path
formArgs - get or post args
httpArgs - http headers
content - _more_
Throws:
Exception - On badness

writeLine

protected void writeLine(String line)
                  throws Exception
Write the line to the output

Parameters:
line - Line of text
Throws:
Exception - On badness

writeResult

public void writeResult(boolean ok,
                        String content,
                        String type)
                 throws Exception
Write header and content

Parameters:
ok - Was ok
content - The content to write
type - Type of content
Throws:
Exception - On badness

writeResult

public void writeResult(int code,
                        String content,
                        String type)
                 throws Exception
_more_

Parameters:
code - _more_
content - _more_
type - _more_
Throws:
Exception - _more_

writeResult

public void writeResult(boolean ok,
                        StringBuffer content,
                        String type)
                 throws Exception
_more_

Parameters:
ok - _more_
content - _more_
type - _more_
Throws:
Exception - _more_

writeResult

public void writeResult(int code,
                        StringBuffer content,
                        String type)
                 throws Exception
_more_

Parameters:
code - _more_
content - _more_
type - _more_
Throws:
Exception - _more_

writeXml

public void writeXml(StringBuffer content)
              throws Exception
_more_

Parameters:
content - _more_
Throws:
Exception - _more_

writeHtml

public void writeHtml(StringBuffer content)
               throws Exception
_more_

Parameters:
content - _more_
Throws:
Exception - _more_

writeResult

public void writeResult(boolean ok,
                        byte[] content,
                        String type)
                 throws Exception
_more_

Parameters:
ok - _more_
content - _more_
type - _more_
Throws:
Exception - On badness

writeResult

public void writeResult(int code,
                        byte[] content,
                        String type)
                 throws Exception
_more_

Parameters:
code - _more_
content - _more_
type - _more_
Throws:
Exception - _more_

writeResult

public void writeResult(int code,
                        InputStream inputStream,
                        String type)
                 throws Exception
_more_

Parameters:
code - _more_
inputStream - _more_
type - _more_
Throws:
Exception - _more_

writeHeader

protected void writeHeader(int code,
                           long length,
                           String type)
                    throws Exception
_more_

Parameters:
code - return code
length - _more_
type - _more_
Throws:
Exception - On badness

redirect

public void redirect(String url)
              throws Exception
_more_

Parameters:
url - _more_
Throws:
Exception - _more_

writeHeaderArgs

protected void writeHeaderArgs()
                        throws Exception
_more_

Throws:
Exception - _more_

writeBytes

protected void writeBytes(InputStream fis,
                          String type,
                          long length)
                   throws Exception
Transfer bytes

Parameters:
fis - input stream
type - _more_
length - _more_
Throws:
Exception - On badness