Package org.simpleframework.http.core
Class RequestReader
- java.lang.Object
-
- org.simpleframework.http.core.RequestReader
-
- All Implemented Interfaces:
java.lang.Runnable,Operation
class RequestReader extends java.lang.Object implements Operation
TheRequestReaderobject 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:
Reactor
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelchannelThis is the channel object associated with the collector.private CollectorcollectorThis is the collector used to consume the entity bytes.private ControllercontrollerThis is the selector used to process the collection events.private TracetraceThis is used to collect any trace information.
-
Constructor Summary
Constructors Constructor Description RequestReader(Controller controller, Collector collector)Constructor for theRequestReaderobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()This is used to cancel the operation if it has timed out.java.nio.channels.SocketChannelgetChannel()This is theSocketChannelused to determine if the connection has some bytes that can be read.TracegetTrace()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 Detail
-
controller
private final Controller controller
This is the selector used to process the collection events.
-
collector
private final Collector collector
This is the collector used to consume the entity bytes.
-
channel
private final Channel channel
This is the channel object associated with the collector.
-
trace
private final Trace trace
This is used to collect any trace information.
-
-
Constructor Detail
-
RequestReader
public RequestReader(Controller controller, Collector collector)
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 Detail
-
getTrace
public Trace 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
public java.nio.channels.SocketChannel 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.- Specified by:
runin interfacejava.lang.Runnable
-
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.
-
-