Class HttpServer.RequestHandler

java.lang.Object
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 Details

  • Constructor Details

    • RequestHandler

      public RequestHandler(HttpServer server, Socket socket) throws Exception
      Ctor
      Parameters:
      server - The server
      socket - The socket
      Throws:
      Exception - On badness
  • Method Details

    • 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=valueinvalid input: '&' 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