Interface HTTPEngine

All Superinterfaces:
org.omegazero.http.util.HTTPResponder
All Known Implementing Classes:
AbstractHTTPEngine

public interface HTTPEngine extends org.omegazero.http.util.HTTPResponder
HTTP server implementation interface.

An instance of a HTTPEngine is associated with one connection by a client.
  • Field Summary

    Fields inherited from interface org.omegazero.http.util.HTTPResponder

    EMPTY_BYTE_ARRAY
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called when the connection to the client closes.
    org.omegazero.net.socket.SocketConnection
    Returns the SocketConnection to the client associated with this instance.
    void
    processData(byte[] data)
    Processes the given data received over the connection from the client.
    default void
    respondError(org.omegazero.http.common.HTTPRequest request, int status, String message, String... headers)
    Selects an appropriate HTTPErrdoc template and generates a response body using it.
    void
    respondError(org.omegazero.http.common.HTTPRequest request, int status, String title, String message, String... headers)
    Selects an appropriate HTTPErrdoc template and generates a response body using it.

    Methods inherited from interface org.omegazero.http.util.HTTPResponder

    respond, respond
  • Method Details

    • processData

      void processData(byte[] data)
      Processes the given data received over the connection from the client.
      Parameters:
      data - Incoming data of a client to process
    • close

      void close()
      Called when the connection to the client closes.
    • getDownstreamConnection

      org.omegazero.net.socket.SocketConnection getDownstreamConnection()
      Returns the SocketConnection to the client associated with this instance.
      Returns:
      The SocketConnection to the client
    • respondError

      default void respondError(org.omegazero.http.common.HTTPRequest request, int status, String message, String... headers)
      Selects an appropriate HTTPErrdoc template and generates a response body using it.

      The title is selected using HTTPStatus.getStatusName(int) based on the given status; if the given status is not defined by HTTPStatus, behavior is undefined. The resulting body is sent as a HTTP response with the given status and headers.

      Parameters:
      request - The request to respond to
      status - The status code of the response
      message - Error message
      headers - Headers to send in the response. See
      invalid reference
      #respond(HTTPMessage, int, byte[], String...)
      for more information
      Since:
      3.6.1
      See Also:
    • respondError

      void respondError(org.omegazero.http.common.HTTPRequest request, int status, String title, String message, String... headers)
      Selects an appropriate HTTPErrdoc template and generates a response body using it.

      The resulting body is sent as a HTTP response with the given status and headers.

      Parameters:
      request - The request to respond to
      status - The status code of the response
      title - Title of the error message
      message - Error message
      headers - Headers to send in the response. See
      invalid reference
      #respond(HTTPMessage, int, byte[], String...)
      for more information
      See Also: