Package org.simpleframework.http.message
Class EntityConsumer
java.lang.Object
org.simpleframework.http.message.EntityConsumer
- All Implemented Interfaces:
ByteConsumer
The
EntityConsumer
object is used to consume data
from a cursor and build a request entity. Each constituent part of
the entity is consumed from the pipeline and can be acquired from
this consumer object. The Header
and Body
can be used to extract the individual parts of the entity.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BodyConsumer
This is used to consume the body for the request entity.protected ContinueDispatcher
This is used to determine if there a continue is expected.protected ConsumerFactory
This is used to create a body consumer for the entity.protected RequestConsumer
This is used to consume the header for the request entity.protected Trace
This is used to trace the progress of the request consumption. -
Constructor Summary
ConstructorsConstructorDescriptionEntityConsumer
(Allocator allocator, Channel channel) Constructor for theEntityConsumer
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
consume
(ByteCursor cursor) This consumes the header and body from the cursor.getBody()
This is used to acquire the body for this HTTP entity.This provides the HTTP request header for the entity.boolean
This is determined finished when the body has been consumed.boolean
This is used to determine if the header has finished.
-
Field Details
-
dispatcher
This is used to determine if there a continue is expected. -
factory
This is used to create a body consumer for the entity. -
header
This is used to consume the header for the request entity. -
body
This is used to consume the body for the request entity. -
trace
This is used to trace the progress of the request consumption.
-
-
Constructor Details
-
EntityConsumer
Constructor for theEntityConsumer
object. This is used to build an entity from the constituent parts. Once all of the parts have been consumed they are available from the exposed methods of this consumed instance.- Parameters:
allocator
- this is used to allocate the memory usedchannel
- this is the channel used to send a response
-
-
Method Details
-
getBody
This is used to acquire the body for this HTTP entity. This will return a body which can be used to read the content of the message, also if the request is multipart upload then all of the parts are provided asAttachment
objects. Each part can then be read as an individual message.- Returns:
- the body provided by the HTTP request message
-
getHeader
This provides the HTTP request header for the entity. This is always populated and provides the details sent by the client such as the target URI and the query if specified. Also this can be used to determine the method and protocol version used.- Returns:
- the header provided by the HTTP request message
-
consume
This consumes the header and body from the cursor. The header is consumed first followed by the body if there is any. There is a body of there is a Content-Length or a Transfer-Encoding header present. If there is no body then a substitute body is given which has an empty input stream.- Specified by:
consume
in interfaceByteConsumer
- Parameters:
cursor
- used to consumed the bytes for the entity- Throws:
IOException
-
isFinished
public boolean isFinished()This is determined finished when the body has been consumed. If only the header has been consumed then the body will be created using the header information, the body is then read from the cursor, which may read nothing for an empty body.- Specified by:
isFinished
in interfaceByteConsumer
- Returns:
- this returns true if the entity has been built
-
isHeaderFinished
public boolean isHeaderFinished()This is used to determine if the header has finished. Exposing this method ensures the entity consumer can be used to determine if the header for the entity can be consumed before fully processing the entity body of the request message.- Returns:
- determines if the header has been fully consumed
-