A HttpConnection represents the connection of a HTTP client to the server and is created by an instance of a {@link Connector}. It's prime function is to associate {@link Request} and {@link Response} instances with a {@link EndPoint}.
A connection is also the prime mechanism used by jetty to recycle objects without pooling. The {@link Request}, {@link Response}, {@link HttpParser}, {@link HttpGenerator}and {@link HttpFields} instances are all recycled for the duraction ofa connection. Where appropriate, allocated buffers are also kept associated with the connection via the parser and/or generator.
The connection state is held by 3 separate state machines: The request state, the response state and the continuation state. All three state machines must be driven to completion for every request, and all three can complete in any order.
The HttpConnection support protocol upgrade. If on completion of a request, the response code is 101 (switch protocols), then the org.eclipse.jetty.io.Connection request attribute is checked to see if there is a new Connection instance. If so, the new connection is returned from {@link #handle()} and is used for futurehandling of the underlying connection. Note that for switching protocols that don't use 101 responses (eg CONNECT), the response should be sent and then the status code changed to 101 before returning from the handler. Implementors of new Connection types should be careful to extract any buffered data from (HttpParser)http.getParser()).getHeaderBuffer() and (HttpParser)http.getParser()).getBodyBuffer() to initialise their new connection.
|
|
|
|
|
|