Class HttpConnectionThread

java.lang.Object
org.ka2ddo.yaac.webserver.HttpConnectionThread
All Implemented Interfaces:
Runnable

public final class HttpConnectionThread extends Object implements Runnable
This class processes one inbound HTTP connection.
Author:
Andrew Pavlin, KA2DDO
  • Field Details

  • Constructor Details

    • HttpConnectionThread

      public HttpConnectionThread(Socket socket, Map<String,Map<String,PathHandler>> methodToPathToHandlerMap, HttpServer serverInstance) throws IOException
      Create a new connection thread for a particular inbound client.
      Parameters:
      socket - Socket obtained from the ServerSocket.accept() method
      methodToPathToHandlerMap - the Map of Maps of URL paths to PathHandler instances registered within this webserver
      serverInstance - the HttpServer instance which launched this thread
      Throws:
      IOException - if thread could not be created for any reason
  • Method Details

    • run

      public void run()
      DO NOT CALL. Reader thread executor for the enclosing HttpConnectionThread.
      Specified by:
      run in interface Runnable
    • sendError

      public void sendError(int error, Object... args)
      Produce an HTTP error page with the specified HTTP response error code.
      Parameters:
      error - error code (as defined by the HTTP RFC)
      args - other text to be printed after the error code number
      See Also:
    • getServerInstance

      public HttpServer getServerInstance()
      Get the server instance associated with this thread.
      Returns:
      HttpServer that created this thread instance