org.formaria.http
Class HttpSession

java.lang.Object
  extended by org.formaria.http.HttpSession
All Implemented Interfaces:
java.lang.Runnable

public class HttpSession
extends java.lang.Object
implements java.lang.Runnable

Handle a HTTP session

Copyright (c) Formaria Ltd., 2008, see license.txt for details


Constructor Summary
HttpSession(java.net.Socket s, HttpResponseHandler handler)
          Create a new session
 
Method Summary
 void run()
          The runnable method
protected  void sendError(java.lang.String code, java.lang.String message)
          Send an error message as a response
protected  void sendResponse(java.lang.String status, java.lang.String mimeType, java.util.Properties headers, java.io.InputStream data)
          Send the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpSession

public HttpSession(java.net.Socket s,
                   HttpResponseHandler handler)
Create a new session

Parameters:
s - the incoming socket
handler - the response hanlder
Method Detail

run

public void run()
The runnable method

Specified by:
run in interface java.lang.Runnable

sendError

protected void sendError(java.lang.String code,
                         java.lang.String message)
                  throws java.lang.InterruptedException
Send an error message as a response

Parameters:
code - the http reponse
message - the error message throws InterruptedException to stop furhter request processing.
Throws:
java.lang.InterruptedException

sendResponse

protected void sendResponse(java.lang.String status,
                            java.lang.String mimeType,
                            java.util.Properties headers,
                            java.io.InputStream data)
Send the response. As a minimal server this class does not return any files and instead only returns a response code.

Parameters:
status -
mimeType -
props -
data -