|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.jetty.io.AbstractConnection org.eclipse.jetty.server.HttpConnection
public class HttpConnection
A HttpConnection represents the connection of a HTTP client to the server
and is created by an instance of a Connector
. It's prime function is
to associate Request
and Response
instances with a EndPoint
.
A connection is also the prime mechanism used by jetty to recycle objects without
pooling. The Request
, Response
, HttpParser
, HttpGenerator
and HttpFields
instances are all recycled for the duraction of
a 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 handle()
and is used for future
handling 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.
Nested Class Summary | |
---|---|
class |
HttpConnection.Output
|
class |
HttpConnection.OutputWriter
|
Field Summary | |
---|---|
protected Connector |
_connector
|
protected Generator |
_generator
|
protected ServletInputStream |
_in
|
protected HttpConnection.Output |
_out
|
protected Parser |
_parser
|
protected PrintWriter |
_printWriter
|
protected Request |
_request
|
protected HttpFields |
_requestFields
|
protected Response |
_response
|
protected HttpFields |
_responseFields
|
protected Server |
_server
|
protected HttpURI |
_uri
|
protected HttpConnection.OutputWriter |
_writer
|
Fields inherited from class org.eclipse.jetty.io.AbstractConnection |
---|
_endp |
Constructor Summary | |
---|---|
|
HttpConnection(Connector connector,
EndPoint endpoint,
Server server)
Constructor |
protected |
HttpConnection(Connector connector,
EndPoint endpoint,
Server server,
Parser parser,
Generator generator,
Request request)
|
Methods inherited from class org.eclipse.jetty.io.AbstractConnection |
---|
getEndPoint, getTimeStamp, idleExpired, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.jetty.io.Connection |
---|
getTimeStamp, idleExpired |
Field Detail |
---|
protected final Connector _connector
protected final Server _server
protected final HttpURI _uri
protected final Parser _parser
protected final HttpFields _requestFields
protected final Request _request
protected ServletInputStream _in
protected final Generator _generator
protected final HttpFields _responseFields
protected final Response _response
protected HttpConnection.Output _out
protected HttpConnection.OutputWriter _writer
protected PrintWriter _printWriter
Constructor Detail |
---|
public HttpConnection(Connector connector, EndPoint endpoint, Server server)
protected HttpConnection(Connector connector, EndPoint endpoint, Server server, Parser parser, Generator generator, Request request)
Method Detail |
---|
public static HttpConnection getCurrentConnection()
protected static void setCurrentConnection(HttpConnection connection)
public Parser getParser()
public int getRequests()
public Server getServer()
public Object getAssociatedObject()
public void setAssociatedObject(Object associatedObject)
associatedObject
- The associatedObject to set.public Connector getConnector()
public HttpFields getRequestFields()
public HttpFields getResponseFields()
public boolean isConfidential(Request request)
getConnector()
.isCondidential
(request), or false
if there is no connector.public boolean isIntegral(Request request)
request
-
true
if there is a connector
and it considers request
to be integral
public boolean getResolveNames()
false
(this method is not yet implemented)public Request getRequest()
public Response getResponse()
public ServletInputStream getInputStream() throws IOException
If the associated response has the Expect header set to 100 Continue, then accessing the input stream indicates that the handler/servlet is ready for the request body and thus a 100 Continue response is sent.
IOException
public ServletOutputStream getOutputStream()
public PrintWriter getPrintWriter(String encoding)
PrintWriter
wrapping the output stream
. The writer is created if it
does not already exist.public boolean isResponseCommitted()
public Connection handle() throws IOException
Connection
handle
in interface Connection
IOException
public void scheduleTimeout(Timeout.Task task, long timeoutMs)
public void cancelTimeout(Timeout.Task task)
public void reset(boolean returnBuffers)
protected void handleRequest() throws IOException
IOException
public void commitResponse(boolean last) throws IOException
IOException
public void completeResponse() throws IOException
IOException
public void flushResponse() throws IOException
IOException
public Generator getGenerator()
public boolean isIncluding()
public void include()
public void included()
public boolean isIdle()
isIdle
in interface Connection
public boolean isSuspended()
isSuspended
in interface Connection
Connection.isSuspended()
public void closed()
Connection
closed
in interface Connection
public boolean isExpecting100Continues()
public boolean isExpecting102Processing()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |