Interface HTTPProcessor

All Known Implementing Classes:
HTTP11Processor, HTTPS11Processor

public interface HTTPProcessor
Generic interface that is used by all the processors to allow worker threads and other hooks into the processing of the requests and responses.
Author:
Brian Pontarelli
  • Method Details

    • close

      ProcessorState close(boolean endOfStream) throws IOException
      Closes the processing. In some cases, the process of closing a connection might require additional work, like shutting down TLS. Therefore, this method can interrupt a normal shutdown.
      Parameters:
      endOfStream - True if the stream is being closed due to an unexpected end-of-stream.
      Returns:
      The new state of the processor.
      Throws:
      IOException - If the close operation failed for any reason.
    • failure

      void failure(Throwable t)
      Signals to the processor that the request handling failed in some way.
      Parameters:
      t - The exception that caused the failure, it there was one.
    • initialKeyOps

      int initialKeyOps()
      Allows the HTTPProcessor to determine what the initial key operations are for the SelectionKey. For TLS, this is usually READ and WRITE in order to handle the handshake. For non-TLS, this is usually just READ.
      Returns:
      The initial interested ops.
      See Also:
    • lastUsed

      long lastUsed()
      Returns:
      The instant that this processor was last used.
    • read

      ProcessorState read(ByteBuffer buffer) throws IOException
      Allows the HTTPProcessor to handle bytes that were read.
      Parameters:
      buffer - The bytes read from the client.
      Returns:
      The new state of the HTTPProcessor.
      Throws:
      IOException - If any I/O operations failed.
    • readBuffer

      ByteBuffer readBuffer() throws IOException
      Returns:
      The current read buffer or null if the state has changed or there we aren't expecting to read.
      Throws:
      IOException - If any I/O operations failed.
    • readThroughput

      long readThroughput()
      Returns:
      The bytes per second throughput read by this processor.
    • state

      Returns:
      The current state of the HTTPProcessor.
    • writeBuffers

      ByteBuffer[] writeBuffers() throws IOException
      Returns:
      The current write buffer(s) and never null.
      Throws:
      IOException - If any I/O operations failed.
    • writeThroughput

      long writeThroughput()
      Returns:
      The bytes per second throughput wrote by this processor.
    • wrote

      ProcessorState wrote(long num) throws IOException
      Called by the selector to tell the HTTPProcessor that bytes were written back to the client.
      Parameters:
      num - The number of bytes written.
      Returns:
      The new state of the HTTPProcessor.
      Throws:
      IOException - If any I/O operations failed.