Package org.simpleframework.http.core
Class RequestReader
java.lang.Object
org.simpleframework.http.core.RequestReader
The
RequestReader object is used to read the bytes
that form the request entity. In order to execute a read operation
the socket must be read ready. This is determined using the socket
object, which is registered with a controller. If at any point the
reading results in an error the operation is cancelled and the
collector is closed, which shuts down the connection.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelThis is the channel object associated with the collector.private final CollectorThis is the collector used to consume the entity bytes.private final ControllerThis is the selector used to process the collection events.private final TraceThis is used to collect any trace information. -
Constructor Summary
ConstructorsConstructorDescriptionRequestReader(Controller controller, Collector collector) Constructor for theRequestReaderobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()This is used to cancel the operation if it has timed out.This is theSocketChannelused to determine if the connection has some bytes that can be read.getTrace()This is used to acquire the trace object that is associated with the operation.voidrun()Thisrunmethod is used to collect the bytes from the connected channel.
-
Field Details
-
controller
This is the selector used to process the collection events. -
collector
This is the collector used to consume the entity bytes. -
channel
This is the channel object associated with the collector. -
trace
This is used to collect any trace information.
-
-
Constructor Details
-
RequestReader
Constructor for theRequestReaderobject. This is used to collect the data required to compose a HTTP request. Once all the data has been read by this it is dispatched.- Parameters:
controller- the controller object used to process eventscollector- this is the task used to collect the entity
-
-
Method Details
-
getTrace
This is used to acquire the trace object that is associated with the operation. A trace object is used to collection details on what operations are being performed. For instance it may contain information relating to I/O events or errors. -
getChannel
This is theSocketChannelused to determine if the connection has some bytes that can be read. If it contains any data then that data is read from and is used to compose the request entity, which consists of a HTTP header and body.- Specified by:
getChannelin interfaceOperation- Returns:
- this returns the socket for the connected pipeline
-
run
public void run()Thisrunmethod is used to collect the bytes from the connected channel. If a sufficient amount of data is read from the socket to form a HTTP entity then the collector uses theSelectorobject to dispatch the request. This is sequence of events that occur for each transaction. -
cancel
public void cancel()This is used to cancel the operation if it has timed out. If the retry is waiting too long to read content from the socket then the retry is cancelled and the underlying transport is closed. This helps to clean up occupied resources.
-