prupp
Class HTTPHeaderHandler

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--prupp.HTTPHeaderHandler

public class HTTPHeaderHandler
extends java.lang.Thread

Do some magic.

 Handles the (client)requst to the Proxy, figures out what to do. 

 A typical request:

 GET /index.html HTTP/1.0
 Proxy-Connection: Keep-Alive
 User-Agent: Mozilla/4.04j2 [en] (X11; I; SunOS 5.5.1 sun4u)
 Pragma: no-cache
 Host: www.ludd.luth.se
 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png
 Accept-Language: en
 Accept-Charset: iso-8859-1,*,utf-8
 

 SPEC from HTTP-1.1 (RFC 2068)
 Request        = Request-Line              ; Section 5.1
 *( general-header         ; Section 4.5
 | request-header         ; Section 5.3
 | entity-header )        ; Section 7.1
 CRLF
 [ message-body ]          ; Section 7.2
 Request-Line   = Method SP Request-URI SP HTTP-Version CRLF
 


Field Summary
protected  boolean cacheAllowed
          are we allowed to cache the page?
protected  java.lang.String request
          the current request
protected  boolean useCached
          are we allowed to use the cache?
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
HTTPHeaderHandler(java.net.Socket socket)
          reads the HTTP Header from the socket and determine what to do.
 
Method Summary
 java.lang.String getConnection()
          Get the connection of this request for status-pages etc.
 java.net.InetAddress getInetAddress()
          Get the InetAddress of user
 java.util.Date getStarted()
          Get the time this connection started for status-pages etc.
 java.lang.String getStatus()
          Get the current status of this request so we can build status-pages etc.
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.
 void run()
          Reads the request and finds out which type of handler to use tries to use the cache if possible and if not use a webreader to handle the fetching and sending of the file.
protected  boolean setURL(HTTPHeader header)
          Try to make an URL of the request.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

useCached

protected boolean useCached
are we allowed to use the cache?

cacheAllowed

protected boolean cacheAllowed
are we allowed to cache the page?

request

protected java.lang.String request
the current request
Constructor Detail

HTTPHeaderHandler

public HTTPHeaderHandler(java.net.Socket socket)
reads the HTTP Header from the socket and determine what to do.
Parameters:
socket - the client were talking to.
Method Detail

run

public void run()
Reads the request and finds out which type of handler to use tries to use the cache if possible and if not use a webreader to handle the fetching and sending of the file.
Overrides:
run in class java.lang.Thread

readContent

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.

setURL

protected boolean setURL(HTTPHeader header)
Try to make an URL of the request. Can also be some special page that this proxy provides (like proxy.status). This little thingy sets us up for correctness when the user is requesting a Meta-page (a page the proxy provides, like proxy.status).
Parameters:
header - the HTTP header for this request.

getStatus

public java.lang.String getStatus()
Get the current status of this request so we can build status-pages etc.
Returns:
the current status of this connection.

getConnection

public java.lang.String getConnection()
Get the connection of this request for status-pages etc.
Returns:
the current connection.

getStarted

public java.util.Date getStarted()
Get the time this connection started for status-pages etc.
Returns:
the Date this connections started

getInetAddress

public java.net.InetAddress getInetAddress()
Get the InetAddress of user