/** * 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 canceled and the underlying transport is * closed. This helps to clean up occupied resources. */ public void cancel() { try { channel.close(); } catch(Throwable e) { return; } } }
/** * This can be used to retrieve certain attributes about * this <code>Response</code>. The attributes contains certain * properties about the <code>Response</code>. For example if * this Response goes over a secure line then there may be any * arbitrary attributes. * * @return the response attributes of that have been set */ public Map getAttributes() { return channel.getAttributes(); }
/** * 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. * * @return the socket channel used by this collector object */ public SocketChannel getSocket() { return channel.getSocket(); } }
/** * Constructor for the <code>Expectation</code> object. This will * create an object that will deliver the continue status code. * Because the transport performs an asynchronous write this will * not block the execution of this method and delay execution. * * @param channel this is the channel used to deliver the prompt */ public Expectation(Channel channel) { this.sender = channel.getSender(); this.trace = channel.getTrace(); }
/** * Constructor for the <code>ContinueDispatcher</code> object. This * will create an object that will deliver the continue status code. * Because the transport performs an asynchronous write this will * not block the execution of this method and delay execution. * * @param channel this is the channel used to deliver the prompt */ public ContinueDispatcher(Channel channel) { this.writer = channel.getWriter(); this.trace = channel.getTrace(); }
/** * The <code>RequestCollector</code> object used to collect the data * from the underlying transport. In order to collect a body this * must be given an <code>Allocator</code> which is used to create * an internal buffer to store the consumed body. * * @param allocator this is the allocator used to buffer data * @param tracker this is the tracker used to create sessions * @param channel this is the channel used to read the data */ public RequestCollector(Allocator allocator, Channel channel) { this.entity = new EntityConsumer(allocator, channel); this.timer = new Timer(MILLISECONDS); this.cursor = channel.getCursor(); this.trace = channel.getTrace(); this.channel = channel; }
/** * Constructor for the <code>RequestReader</code> object. 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. * * @param controller the controller object used to process events * @param collector this is the task used to collect the entity */ public RequestReader(Controller controller, Collector collector){ this.channel = collector.getChannel(); this.trace = channel.getTrace(); this.collector = collector; this.controller = controller; }
/** * This method is used to terminate the connection and commit the * response. Terminating the session before it has been dispatched * is done when there is a protocol or an unexpected I/O error with * the underlying TCP channel. * * @param request this is the session initiating request * @param response this is the session initiating response */ public void terminate(Request request, Response response) { Channel channel = request.getChannel(); Trace trace = channel.getTrace(); try { response.close(); channel.close(); trace.trace(TERMINATE_SOCKET); } catch(Exception cause) { trace.trace(ERROR, cause); } } }
/** * This is used to determine if the request has been transferred * over a secure connection. If the protocol is HTTPS and the * content is delivered over SSL then the request is considered * to be secure. Also the associated response will be secure. * * @return true if the request is transferred securely */ public boolean isSecure() { return channel.isSecure(); }
/** * Constructor for the <code>Challenge</code> object. This is * basically a wrapper for the raw certificate challenge that * will enforce some of the workflow required by HTTPS. * * @param entity this entity containing the request data * @param monitor this monitor used to track the transaction */ public Challenge(Entity entity, Monitor monitor) { this.channel = entity.getChannel(); this.certificate = channel.getCertificate(); this.monitor = monitor; }
/** * Constructor for the <code>BodyEncoderFactory</code> object. * This is used to create producers that can encode data in a HTTP * compliant format. Each producer created will produce its data * and deliver it to the specified sender, should an I/O events * occur such as an error, or completion of the response then * the monitor is notified and the server kernel takes action. * * @param observer this is used to deliver signals to the kernel * @param support this contains details regarding the semantics * @param writer this is used to send to the underlying transport */ public BodyEncoderFactory(BodyObserver observer, Conversation support, Channel channel) { this.writer = channel.getWriter(); this.observer = observer; this.support = support; }
/** * Constructor for the <code>ProducerFactory</code> object. This * is used to create producers that can encode data in a HTTP * compliant format. Each producer created will produce its data * and deliver it to the specified sender, should an I/O events * occur such as an error, or completion of the response then * the monitor is notified and the server kernel takes action. * * @param support this contains details regarding the semantics * @param sender this is used to send to the underlying transport * @param monitor this is used to deliver signals to the kernel */ public ProducerFactory(Conversation support, Channel channel, Monitor monitor) { this.sender = channel.getSender(); this.support = support; this.monitor = monitor; }
/** * Constructor for the <code>FrameCollector</code> object. This is * used to create a collector that will process and dispatch web * socket frames as defined by RFC 6455. * * @param encoder this is the encoder used to send messages * @param session this is the web socket session * @param channel this is the underlying TCP communication channel * @param reactor this is the reactor used for read notifications */ public FrameCollector(FrameEncoder encoder, Session session, Request request, Reactor reactor) { this.processor = new FrameProcessor(encoder, session, request); this.channel = request.getChannel(); this.cursor = channel.getCursor(); this.trace = channel.getTrace(); this.reactor = reactor; }
/** * Constructor for the <code>RequestReader</code> object. 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. * * @param controller the controller object used to process events * @param collector this is the task used to collect the entity */ public RequestReader(Controller controller, Collector collector){ this.channel = collector.getChannel(); this.trace = channel.getTrace(); this.collector = collector; this.controller = controller; }
/** * Constructor for the <code>ContinueDispatcher</code> object. This * will create an object that will deliver the continue status code. * Because the transport performs an asynchronous write this will * not block the execution of this method and delay execution. * * @param channel this is the channel used to deliver the prompt */ public ContinueDispatcher(Channel channel) { this.writer = channel.getWriter(); this.trace = channel.getTrace(); }
/** * This method is used to terminate the connection and commit the * response. Terminating the session before it has been dispatched * is done when there is a protocol or an unexpected I/O error with * the underlying TCP channel. * * @param request this is the session initiating request * @param response this is the session initiating response */ public void terminate(Request request, Response response) { Channel channel = request.getChannel(); Trace trace = channel.getTrace(); try { response.close(); channel.close(); trace.trace(TERMINATE_SOCKET); } catch(Exception cause) { trace.trace(ERROR, cause); } } }
/** * This is used to determine if the request has been transferred * over a secure connection. If the protocol is HTTPS and the * content is delivered over SSL then the request is considered * to be secure. Also the associated response will be secure. * * @return true if the request is transferred securely */ public boolean isSecure() { return channel.isSecure(); }
/** * Constructor for the <code>Challenge</code> object. This is * basically a wrapper for the raw certificate challenge that * will enforce some of the workflow required by HTTPS. * * @param observer this observer used to track the transaction * @param entity this entity containing the request data */ public Challenge(BodyObserver observer, Entity entity) { this.channel = entity.getChannel(); this.certificate = channel.getCertificate(); this.observer = observer; }
/** * Constructor for the <code>ResponseEntity</code> object. This is * used to create a response instance using the provided request, * entity, and monitor object. To ensure that the response is * compatible with client the <code>Request</code> is used. Also * to ensure the next request can be processed the provided monitor * is used to signal response events to the server kernel. * * @param request this is the request that was sent by the client * @param entity this is the entity that contains the channel * @param monitor this is the monitor used to signal events */ public ResponseEntity(Request request, Entity entity, Monitor monitor) { this.support = new Conversation(request, this); this.buffer = new ResponseBuffer(this, support, entity, monitor); this.channel = entity.getChannel(); this.sender = channel.getSender(); this.trace = channel.getTrace(); this.monitor = monitor; }
/** * Constructor for the <code>BodyEncoderFactory</code> object. * This is used to create producers that can encode data in a HTTP * compliant format. Each producer created will produce its data * and deliver it to the specified sender, should an I/O events * occur such as an error, or completion of the response then * the monitor is notified and the server kernel takes action. * * @param observer this is used to deliver signals to the kernel * @param support this contains details regarding the semantics * @param writer this is used to send to the underlying transport */ public BodyEncoderFactory(BodyObserver observer, Conversation support, Channel channel) { this.writer = channel.getWriter(); this.observer = observer; this.support = support; }