Class AbstractConnectionHandler

java.lang.Object
com.github.toolarium.network.server.handler.impl.AbstractConnectionHandler
All Implemented Interfaces:
IHttpConnectionHandler, Runnable
Direct Known Subclasses:
HttpConnectionHandlerImpl

public abstract class AbstractConnectionHandler extends Object implements IHttpConnectionHandler
Implements the abstract base class for IHttpConnectionHandler.
  • Constructor Details

    • AbstractConnectionHandler

      public AbstractConnectionHandler()
  • Method Details

    • readInFirstLine

      protected String readInFirstLine(BufferedReader br, HttpRequest request) throws IOException
      Read the first line
      Parameters:
      br - the reader
      request - the request
      Returns:
      the first line
      Throws:
      IOException - In case of an I/O error
    • readInBody

      protected String readInBody(BufferedReader reader, int contentLength) throws IOException
      Read in the body
      Parameters:
      reader - the reader
      contentLength - the content length
      Returns:
      the body
      Throws:
      IOException - In case of an I/O error
    • createHttpResponse

      protected IHttpResponse createHttpResponse(IHttpRequest request)
      create a http response
      Parameters:
      request - the reuqest
      Returns:
      the response object
    • getStatusLineAndHeaders

      protected String getStatusLineAndHeaders(IHttpResponse response)
      Get the status line and headers
      Parameters:
      response - the http response
      Returns:
      the status line and headers
    • getBodyAsByteArray

      protected String getBodyAsByteArray(IHttpResponse response)
      Get the body as byte array
      Parameters:
      response - the http response
      Returns:
      the body as byte array