Package org.simpleframework.http.core
Class RequestCollector
- java.lang.Object
-
- org.simpleframework.http.core.RequestCollector
-
class RequestCollector extends java.lang.Object implements Collector
TheRequestCollector
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 theSelector
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
Fields Modifier and Type Field Description private Channel
channel
This is the channel used to acquire the underlying data.private ByteCursor
cursor
This is the cursor used to read and reset the data.private EntityConsumer
entity
This is used to consume the request entity from the channel.private Timer
timer
This represents the time the request collection began at.private Trace
trace
This is the trace used to listen for various collect events.
-
Constructor Summary
Constructors Constructor Description RequestCollector(Allocator allocator, Channel channel)
TheRequestCollector
object used to collect the data from the underlying transport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
collect(Controller controller)
This is used to collect the data from aChannel
which is used to compose the entity.Body
getBody()
This is used to acquire the body for this HTTP entity.Channel
getChannel()
This provides the connected channel for the client.Header
getHeader()
This provides the HTTP request header for the entity.java.nio.channels.SocketChannel
getSocket()
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 Detail
-
entity
private final EntityConsumer entity
This is used to consume the request entity from the channel.
-
cursor
private final ByteCursor cursor
This is the cursor used to read and reset the data.
-
channel
private final Channel channel
This is the channel used to acquire the underlying data.
-
trace
private final Trace trace
This is the trace used to listen for various collect events.
-
timer
private final Timer timer
This represents the time the request collection began at.
-
-
Constructor Detail
-
RequestCollector
public RequestCollector(Allocator allocator, Channel channel)
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 datatracker
- this is the tracker used to create sessionschannel
- this is the channel used to read the data
-
-
Method Detail
-
collect
public void collect(Controller controller) throws java.io.IOException
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.
-
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
public Header 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
public Body 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
public Channel 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
public java.nio.channels.SocketChannel 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
-
-