Package org.simpleframework.http.message
Interface ByteConsumer
-
- All Known Subinterfaces:
BodyConsumer
- All Known Implementing Classes:
ArrayConsumer
,ChunkedConsumer
,EmptyConsumer
,EntityConsumer
,FileUploadConsumer
,FixedLengthConsumer
,HeaderConsumer
,RequestConsumer
,SegmentConsumer
,UpdateConsumer
public interface ByteConsumer
TheByteConsumer
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.- Author:
- Niall Gallagher
- See Also:
ByteCursor
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
consume(org.simpleframework.transport.ByteCursor cursor)
This method is used to consume bytes from the provided cursor.boolean
isFinished()
This is used to determine whether the consumer has finished reading.
-
-
-
Method Detail
-
consume
void consume(org.simpleframework.transport.ByteCursor cursor) throws java.io.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 theByteCursor
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:
java.io.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
-
-