Package org.simpleframework.http.core
Class RequestCollector
java.lang.Object
org.simpleframework.http.core.RequestCollector
The
RequestCollector
object is used to collect all of
the data used to form a request entity. This will collect the data
fragment by fragment from the underlying transport. When all of
the data is consumed and the entity is created and then it is sent
to the Selector
object for processing. If the request
has completed the next request can be collected from the
underlying transport using a new collector object.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Channel
This is the channel used to acquire the underlying data.private final ByteCursor
This is the cursor used to read and reset the data.private final EntityConsumer
This is used to consume the request entity from the channel.private final Timer
This represents the time the request collection began at.private final Trace
This is the trace used to listen for various collect events. -
Constructor Summary
ConstructorsConstructorDescriptionRequestCollector
(Allocator allocator, Channel channel) TheRequestCollector
object used to collect the data from the underlying transport. -
Method Summary
Modifier and TypeMethodDescriptionvoid
collect
(Controller controller) This is used to collect the data from aChannel
which is used to compose the entity.getBody()
This is used to acquire the body for this HTTP entity.This provides the connected channel for the client.This provides the HTTP request header for the entity.This returns the socket channel that is used by the collector to read content from.long
getTime()
This is the time in milliseconds when the request was first read from the underlying channel.
-
Field Details
-
entity
This is used to consume the request entity from the channel. -
cursor
This is the cursor used to read and reset the data. -
channel
This is the channel used to acquire the underlying data. -
trace
This is the trace used to listen for various collect events. -
timer
This represents the time the request collection began at.
-
-
Constructor Details
-
RequestCollector
TheRequestCollector
object used to collect the data from the underlying transport. In order to collect a body this must be given anAllocator
which is used to create an internal buffer to store the consumed body.- Parameters:
allocator
- this is the allocator used to buffer datachannel
- this is the channel used to read the datatracker
- this is the tracker used to create sessions
-
-
Method Details
-
collect
This is used to collect the data from aChannel
which is used to compose the entity. If at any stage there are no ready bytes on the socket the controller provided can be used to queue the collector until such time as the socket is ready to read. Also, should the entity have completed reading all required content it is handed to the controller as ready, which processes the entity as a new client HTTP request.- Specified by:
collect
in interfaceCollector
- Parameters:
controller
- this is the controller used to queue this- Throws:
IOException
-
getTime
public long getTime()This is the time in milliseconds when the request was first read from the underlying channel. The time represented here represents the time collection of this request began. This does not necessarily represent the time the bytes arrived on the receive buffers as some data may have been buffered. -
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. -
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 asPart
objects. Each part can then be read as an individual message. -
getChannel
This provides the connected channel for the client. This is used to send and receive bytes to and from an transport layer. Each channel provided with an entity contains an attribute map which contains information about the connection.- Specified by:
getChannel
in interfaceEntity
- Returns:
- the connected channel for this HTTP entity
-
getSocket
This returns the socket channel that is used by the collector to read content from. This is a selectable socket, in that it can be registered with a Java NIO selector. This ensures that the system can be notified when the socket is ready.- Returns:
- the socket channel used by this collector object
-