com.prolixtech.jaminid
Class Response

java.lang.Object
  extended by com.prolixtech.jaminid.Response

public class Response
extends java.lang.Object

The response class encapsulates an HTTP response. It contains the response data (headers, etc) as well as functions to publish cookies, send files, etc.

Author:
Constantinos Michael TODO

Constructor Summary
Response(int statusCode, Protocol protocol, java.io.OutputStream out, Request masterRequest)
           
 
Method Summary
 byte[] CRLF()
           
 void publishHeader()
          Sends the header to the client.
 void sendCookie15DG(java.lang.String name, java.lang.String value)
          sets a fifteen day cookie
 void sendFile(java.io.File cFile)
          sends a file to the client.
 void setCookie(java.lang.String name, java.lang.String value, java.lang.String path, java.util.Date expires)
          sets a cookie
 void setHeaderLine(ProtocolResponseHeader header, java.lang.String value)
          sets one particular header line
 void setStatus(int statusCode)
          sets the status of the response to a certain HTTP status code
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Response

public Response(int statusCode,
                Protocol protocol,
                java.io.OutputStream out,
                Request masterRequest)
Method Detail

setStatus

public void setStatus(int statusCode)
sets the status of the response to a certain HTTP status code

Parameters:
statusCode - the code to set the status to

sendCookie15DG

public void sendCookie15DG(java.lang.String name,
                           java.lang.String value)
sets a fifteen day cookie

Parameters:
name - the field name
value - the field value

setCookie

public void setCookie(java.lang.String name,
                      java.lang.String value,
                      java.lang.String path,
                      java.util.Date expires)
sets a cookie

Parameters:
name - the field name
value - the field vaLUE
path - the relevant path
expires - the cookie activation day

publishHeader

public void publishHeader()
                   throws java.io.IOException
Sends the header to the client. After this, no more headers can be set, no more cookies can be send

Throws:
java.io.IOException

setHeaderLine

public void setHeaderLine(ProtocolResponseHeader header,
                          java.lang.String value)
sets one particular header line

Parameters:
header -
value -

CRLF

public byte[] CRLF()

sendFile

public void sendFile(java.io.File cFile)
              throws java.lang.Exception
sends a file to the client. Sets the MIME type accordingly

Parameters:
cFile - the file to send
Throws:
java.io.IOException
java.lang.Exception