Interface ByteConsumer

All Known Subinterfaces:
BodyConsumer
All Known Implementing Classes:
ArrayConsumer, BoundaryConsumer, ChunkedConsumer, ContentConsumer, EmptyConsumer, EntityConsumer, FileUploadConsumer, FixedLengthConsumer, HeaderConsumer, PartBodyConsumer, PartConsumer, PartEntryConsumer, PartHeaderConsumer, PartSeriesConsumer, RequestConsumer, SegmentConsumer, TokenConsumer, UpdateConsumer

public interface ByteConsumer
The ByteConsumer object is used to consume and process bytes from a cursor. This is used to consume bytes from a pipeline and process the content in order to produce a valid HTTP message. Using a consumer allows the server to gather and process the data from the stream bit by bit without blocking.

A consumer has completed its task when it has either exhausted its stream, or when it has consume a terminal token. For instance a consumer for a HTTP header will have two CRLF bytes tokens to identify the end of the header, once this has been read any excess bytes are reset on the cursor and it has finished.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is used to consume bytes from the provided cursor.
    boolean
    This is used to determine whether the consumer has finished reading.
  • Method Details

    • consume

      void consume(ByteCursor cursor) throws IOException
      This method is used to consume bytes from the provided cursor. Consuming of bytes from the cursor should be done in such a way that it does not block. So typically only the number of ready bytes in the ByteCursor object should be read. If there are no ready bytes then this method return.
      Parameters:
      cursor - used to consume the bytes from the cursor
      Throws:
      IOException
    • isFinished

      boolean isFinished()
      This is used to determine whether the consumer has finished reading. The consumer is considered finished if it has read a terminal token or if it has exhausted the stream and can not read any more. Once finished the consumed bytes can be parsed.
      Returns:
      true if the consumer has finished reading its content