|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
rabbit.util.RestartableThread
rabbit.proxy.Connection
public class Connection
This is the class that handles one connection And make sure the content is delivered to the client. It reads the request and get the data (from the cache or the web), and filters it and sends the data to the client. If Keepalive is suitable it reads the next request.
Nested Class Summary | |
---|---|
protected class |
Connection.RequestHandler
A container to send around less parameters. |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
Connection(Proxy proxy)
Create a new Connection. |
Method Summary | |
---|---|
HTTPHeader |
checkIfMatch(HTTPHeader header,
Connection.RequestHandler rh)
|
boolean |
checkIPAccess(java.net.Socket sock)
Check if this socket is in the possible range of ip:s being served. |
void |
doError(int statuscode,
java.lang.Exception e)
Send an error (400 Bad Request) to the client. |
void |
doError(int statuscode,
java.lang.String message)
Send an error (400 Bad Request) to the client. |
void |
doWork()
Handle the incomming requests for as long as we can keep the connection alive. |
HTTPHeader |
filterHTTPIn(java.util.List<HTTPFilter> filters,
HTTPHeader in)
Filter the headers using the methods in the vector. |
HTTPHeader |
filterHTTPOut(java.util.List<HTTPFilter> filters,
HTTPHeader in)
Filter the headers using the methods in the vector. |
boolean |
getChunking()
Get the chunking option. |
java.lang.String |
getContentLength()
Get the content length of the response. |
java.lang.String |
getExtraInfo()
Get the extra information for this request. |
boolean |
getKeepalive()
Get the keepalive value. |
boolean |
getMayCache()
Get the state of this request. |
boolean |
getMayFilter()
Get the state of the request. |
boolean |
getMayUseCache()
Get the state of this request. |
boolean |
getMeta()
Get the state of this request. |
java.lang.String |
getPassWord()
Get the password of the client. |
Proxy |
getProxy()
Get the proxy that this connection is working for. |
java.lang.String |
getRequestLine()
Get the current request line |
StandardResponseHeaders |
getResponseHandler()
|
java.net.Socket |
getSocket()
Get the Socket that is being served. |
java.util.Date |
getStarted()
Get the time this Connection was started. |
java.lang.String |
getStatus()
Get the status of this Connection |
java.lang.String |
getStatusCode()
Get the status code of the request. |
java.lang.String |
getUserName()
Get the username of the client. |
void |
handleMeta(HTTPHeader header)
Handle a meta page. |
void |
handleRequest(HTTPHeader header)
Handle a request by getting the datastream (from the cache or the web). |
HTTPHeader |
is304(HTTPHeader in,
Connection.RequestHandler rh)
Check if the request allows us to use a "304 Not modified" response. |
protected boolean |
readChunkedContent(HTTPHeader header)
|
protected boolean |
readContent(HTTPHeader header)
If this request has a body (due to some post or so) read it in and append it to the request. |
protected boolean |
readMultipartContent(HTTPHeader header,
java.lang.String ct)
If this request has a multipart body read it and append it to the request. |
protected void |
send(HTTPHeader header)
Send a header to the client. |
void |
setAddedIMS(boolean b)
|
void |
setAddedINM(boolean b)
|
void |
setChunking(boolean b)
Set the chunking option. |
void |
setContentLength(java.lang.String cl)
Set the content length of the response. |
void |
setExtraInfo(java.lang.String exinfo)
Set the extra information for this request. |
void |
setKeepalive(boolean keepalive)
Set keepalive to a new value. |
void |
setMayCache(boolean cacheAllowed)
Set the state of this request. |
void |
setMayFilter(boolean filterAllowed)
Get the state of this request. |
void |
setMayUseCache(boolean usecache)
Set the state of this request. |
void |
setMeta(boolean meta)
Set the state of this request. |
void |
setMustRevalidate(boolean b)
|
void |
setPassWord(java.lang.String password)
Set the password of the client. |
void |
setSocket(java.nio.channels.SocketChannel socket)
Give this connection a socket to handle |
protected boolean |
setupStreams()
Set up the streams used for reading request and sending data to and from the client. |
void |
setUserName(java.lang.String username)
Set the user name of the client. |
java.util.Properties |
splitArgs(java.lang.String params)
splits the CGI-paramsstring into variables and values. |
Methods inherited from class rabbit.util.RestartableThread |
---|
run, start |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Connection(Proxy proxy)
proxy
- the Proxy to handle connections for.Method Detail |
---|
public void setSocket(java.nio.channels.SocketChannel socket)
socket
- the Socket that is requesting service.public boolean checkIPAccess(java.net.Socket sock)
sock
- the Socket to check.
public void doWork()
doWork
in class RestartableThread
protected boolean setupStreams()
protected boolean readContent(HTTPHeader header)
protected boolean readChunkedContent(HTTPHeader header)
protected boolean readMultipartContent(HTTPHeader header, java.lang.String ct)
public HTTPHeader filterHTTPIn(java.util.List<HTTPFilter> filters, HTTPHeader in)
filters
- a List with Methods.in
- the request or response header.
public HTTPHeader filterHTTPOut(java.util.List<HTTPFilter> filters, HTTPHeader in)
filters
- a List with Methods.in
- the request or response header.
protected void send(HTTPHeader header)
header
- the HTTPHeader to send.public HTTPHeader checkIfMatch(HTTPHeader header, Connection.RequestHandler rh)
public HTTPHeader is304(HTTPHeader in, Connection.RequestHandler rh)
in
- the request being made.rh
- the RequestHandler for this requestpublic void handleRequest(HTTPHeader header)
header
- the request made.public void handleMeta(HTTPHeader header)
header
- the request being made.public java.util.Properties splitArgs(java.lang.String params)
params
- the CGI-querystring.
public void doError(int statuscode, java.lang.String message)
statuscode
- the status code of the error.message
- the error message to tell the client.public void doError(int statuscode, java.lang.Exception e)
statuscode
- the status code of the error.e
- the exception to tell the client.public Proxy getProxy()
public java.lang.String getStatus()
public java.util.Date getStarted()
public void setUserName(java.lang.String username)
username
- the username of the client.public java.lang.String getUserName()
public void setPassWord(java.lang.String password)
password
- the password of the client.public java.lang.String getPassWord()
public void setKeepalive(boolean keepalive)
keepalive
- the new keepalive value.public boolean getKeepalive()
public void setChunking(boolean b)
b
- if true this connection should use chunking.public boolean getChunking()
public void setMeta(boolean meta)
meta
- true if this request is a metapage request, false otherwise.public boolean getMeta()
public void setMayUseCache(boolean usecache)
usecache
- true if we may use the cache for this request, false otherwise.public boolean getMayUseCache()
public void setMayCache(boolean cacheAllowed)
cacheAllowed
- true if we may cache the response, false otherwise.public boolean getMayCache()
public void setMayFilter(boolean filterAllowed)
filterAllowed
- true if we may filter the response, false otherwise.public boolean getMayFilter()
public void setAddedINM(boolean b)
public void setAddedIMS(boolean b)
public void setMustRevalidate(boolean b)
public java.net.Socket getSocket()
public java.lang.String getRequestLine()
public java.lang.String getStatusCode()
public java.lang.String getExtraInfo()
public void setExtraInfo(java.lang.String exinfo)
exinfo
- the new extra information to set.public void setContentLength(java.lang.String cl)
cl
- the new content length.public java.lang.String getContentLength()
public StandardResponseHeaders getResponseHandler()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |