|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--rabbit.util.RestartableThread | +--rabbit.proxy.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.
Field Summary |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
Connection()
Create a new Connection. |
|
Connection(java.net.Socket socket)
Create a new Connection for a given socket. |
Method Summary | |
HTTPHeader |
checkIfMatch(HTTPHeader header,
NCacheEntry entry)
|
boolean |
checkIPAccess(java.net.Socket socket)
Check if this socket is in the possible range of ip:s being served. |
protected void |
closeDown()
Close down nicely. |
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 |
filterHTTP(java.util.Vector filters,
HTTPHeader in)
Filter the headers using the methods in the vector. |
HTTPHeader |
get200()
Get a 200 Ok header |
HTTPHeader |
get304(HTTPHeader oldresp)
Get a 304 Not Modified header for the given old header |
HTTPHeader |
get400(java.lang.Exception exception)
Get a 400 Bad Request header for the given exception. |
HTTPHeader |
get403()
Get a 403 Forbidden header. |
HTTPHeader |
get407(java.lang.String realm,
java.net.URL url)
Get a 407 Proxy Authentication Required for the given realm and url. |
HTTPHeader |
get412()
Get a 412 Precondition Failed header. |
HTTPHeader |
get417(java.lang.String expectation)
Get a 417 Expectation Failed header. |
HTTPHeader |
get500(java.lang.Throwable exception)
Get a 500 Internal Server Error header for the given exception. |
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. |
static HTTPHeader |
getHeader()
Get a new HTTPHeader. |
static HTTPHeader |
getHeader(java.lang.String statusLine)
Get a new HTTPHeader initialized with some data. |
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. |
protected Handler |
getNewInstance(java.lang.Class cls,
HTTPHeader header,
HTTPHeader webheader,
java.io.InputStream contentStream,
MultiOutputStream out,
boolean maycache,
boolean mayfilter,
long size)
Get a new Handler for the given request made. |
java.lang.String |
getPassWord()
Get the password of the client. |
java.lang.String |
getRequestLine()
Get the current request line |
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). |
protected void |
handleSSL(HTTPHeader header)
Handle the SSL request |
HTTPHeader |
is304(HTTPHeader in,
NCacheEntry entry)
Check if the request allows us to use a "304 Not modified" response. |
boolean |
isSSLRequest(HTTPHeader header)
Check to see if this header is an SSL 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 void |
send(HTTPHeader header)
Send a header to the client. |
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 |
setPassWord(java.lang.String password)
Set the password of the client. |
void |
setSocket(java.net.Socket 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. |
protected java.util.Properties |
splitArgs(java.lang.String params)
splits the CGI-paramsstring into variables and values. |
boolean |
sslIsAllowed(HTTPHeader header)
Are we allowed to proxy ssl-type connections ? |
Methods inherited from class rabbit.util.RestartableThread |
run, start |
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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()
public Connection(java.net.Socket socket)
socket
- the Socket that is requesting service.Method Detail |
public void setSocket(java.net.Socket socket)
socket
- the Socket that is requesting service.protected void closeDown()
public boolean checkIPAccess(java.net.Socket socket)
socket
- the Socket to check.
public void doWork()
doWork
in class RestartableThread
protected boolean setupStreams()
protected boolean readContent(HTTPHeader header)
public HTTPHeader filterHTTP(java.util.Vector filters, HTTPHeader in)
filters
- a Vector with Methods.in
- the request or response header.
protected void send(HTTPHeader header)
header
- the HTTPHeader to send.protected Handler getNewInstance(java.lang.Class cls, HTTPHeader header, HTTPHeader webheader, java.io.InputStream contentStream, MultiOutputStream out, boolean maycache, boolean mayfilter, long size)
cls
- the Class of the handler to create.header
- the request.webheader
- the response.contentStream
- the data to read.out
- the client (and possibly the cache).maycache
- if the handler may cache the response.mayfilter
- if the handler may filter the response.size
- the Size of the data beeing handled (-1 = unknown length).public HTTPHeader checkIfMatch(HTTPHeader header, NCacheEntry entry)
public HTTPHeader is304(HTTPHeader in, NCacheEntry entry)
in
- the request being made.entry
- the cache entry.public void handleRequest(HTTPHeader header)
header
- the request made.public void handleMeta(HTTPHeader header)
header
- the request being made.public boolean isSSLRequest(HTTPHeader header)
header
- the header to check.
protected void handleSSL(HTTPHeader header)
header
- the Connect request header.public boolean sslIsAllowed(HTTPHeader header)
protected 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.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 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 static HTTPHeader getHeader()
public static HTTPHeader getHeader(java.lang.String statusLine)
public HTTPHeader get200()
public HTTPHeader get304(HTTPHeader oldresp)
oldresp
- the cached header.
public HTTPHeader get400(java.lang.Exception exception)
exception
- the Exception handled.
public HTTPHeader get403()
public HTTPHeader get407(java.lang.String realm, java.net.URL url)
realm
- the realm that requires auth.url
- the URL of the request made.
public HTTPHeader get412()
public HTTPHeader get417(java.lang.String expectation)
public HTTPHeader get500(java.lang.Throwable exception)
exception
- the Exception made.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |