|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openqa.jetty.http.HttpConnection
public class HttpConnection
A HTTP Connection. This class provides the generic HTTP handling for a connection to a HTTP server. An instance of HttpConnection is normally created by a HttpListener and then given control in order to run the protocol handling before and after passing a request to the HttpServer of the HttpListener. This class is not synchronized as it should only ever be known to a single thread.
HttpListener
,
HttpServer
Field Summary | |
---|---|
protected int |
_dotVersion
|
protected boolean |
_keepAlive
|
protected boolean |
_persistent
|
protected HttpRequest |
_request
|
protected HttpResponse |
_response
|
Fields inherited from interface org.openqa.jetty.util.OutputObserver |
---|
__CLOSED, __CLOSING, __COMMITING, __FIRST_WRITE, __RESET_BUFFER |
Constructor Summary | |
---|---|
HttpConnection(HttpListener listener,
InetAddress remoteAddr,
InputStream in,
OutputStream out,
Object connection)
Constructor. |
Method Summary | |
---|---|
protected void |
associateThread()
|
void |
close()
Close the connection. |
protected void |
commit()
|
protected void |
destroy()
Destroy the connection. |
protected void |
disassociateThread()
|
protected void |
firstWrite()
Setup the reponse output stream. |
void |
forceClose()
Force the connection to not be persistent. |
Object |
getConnection()
Get the underlying connection object. |
String |
getDefaultScheme()
Get the listeners Default scheme. |
HttpServer |
getHttpServer()
Get the listeners HttpServer . |
HttpTunnel |
getHttpTunnel()
|
HttpInputStream |
getInputStream()
Get the connections InputStream. |
HttpListener |
getListener()
Get the connections listener. |
Object |
getObject()
Get associated object. |
HttpOutputStream |
getOutputStream()
Get the connections OutputStream. |
String |
getRemoteAddr()
Get the Remote address. |
String |
getRemoteHost()
Get the Remote address. |
InetAddress |
getRemoteInetAddress()
Get the Remote address. |
int |
getRemotePort()
Get the remote Port . |
HttpRequest |
getRequest()
Get the request. |
HttpResponse |
getResponse()
Get the response. |
String |
getServerAddr()
Get the listeners HttpServer. |
String |
getServerName()
Get the listeners HttpServer. |
int |
getServerPort()
Get the listeners Port . |
void |
handle()
Handle the connection. |
boolean |
handleNext()
Handle next request off the connection. |
boolean |
isThrottled()
|
void |
outputNotify(OutputStream out,
int action,
Object ignoredData)
Output Notifications. |
protected void |
readRequest()
|
protected void |
recycle()
Recycle the connection. |
protected HttpContext |
service(HttpRequest request,
HttpResponse response)
Service a Request. |
void |
setHttpTunnel(HttpTunnel tunnel)
Set a HttpTunnel for the connection. |
void |
setObject(Object o)
Set associated object. |
void |
setThrottled(boolean throttled)
|
protected void |
statsRequestEnd()
|
protected void |
statsRequestStart()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HttpRequest _request
protected HttpResponse _response
protected boolean _persistent
protected boolean _keepAlive
protected int _dotVersion
Constructor Detail |
---|
public HttpConnection(HttpListener listener, InetAddress remoteAddr, InputStream in, OutputStream out, Object connection)
listener
- The listener that created this connection.remoteAddr
- The address of the remote end or null.in
- InputStream to read request(s) from.out
- OutputputStream to write response(s) to.connection
- The underlying connection object, most likely
a socket. This is not used by HttpConnection other than to make
it available via getConnection().Method Detail |
---|
public InetAddress getRemoteInetAddress()
public String getRemoteAddr()
public String getRemoteHost()
public HttpInputStream getInputStream()
public HttpOutputStream getOutputStream()
public Object getConnection()
public HttpRequest getRequest()
public HttpResponse getResponse()
public void forceClose()
public void close() throws IOException
IOException
public HttpListener getListener()
public HttpServer getHttpServer()
public String getDefaultScheme()
public String getServerName()
public String getServerAddr()
public int getServerPort()
public int getRemotePort()
public boolean isThrottled()
public void setThrottled(boolean throttled)
throttled
- True if this connections state has been altered due
to low resources.public Object getObject()
public void setObject(Object o)
o
- An object associated with the connecton.public HttpTunnel getHttpTunnel()
public void setHttpTunnel(HttpTunnel tunnel)
tunnel
- The HttpTunnel set for the connection or null.public void outputNotify(OutputStream out, int action, Object ignoredData) throws IOException
outputNotify
in interface OutputObserver
out
- The output stream observed.action
- The action.ignoredData
- Data associated with the event.
IOException
HttpOutputStream
protected void firstWrite() throws IOException
IOException
protected void commit() throws IOException
IOException
protected HttpContext service(HttpRequest request, HttpResponse response) throws HttpException, IOException
request
- The requestresponse
- The response
HttpException
IOException
public final void handle()
protected void associateThread()
protected void disassociateThread()
protected void readRequest() throws IOException
IOException
public boolean handleNext()
If a HttpTunnel has been set on this connection, it's handle method is called and when that completes, false is return from this method.
The Connection is set as a ThreadLocal of the calling thread and is available via the getHttpConnection() method.
protected void statsRequestStart()
protected void statsRequestEnd()
protected void recycle()
protected void destroy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |