com.prolixtech.jaminid

Class 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.

Constructor Summary

Response(int statusCode, Protocol protocol, OutputStream out, Request masterRequest)

Method Summary

byte[]
CRLF()
void
publishHeader()
Sends the header to the client.
void
sendCookie15DG(String name, String value)
sets a fifteen day cookie
void
sendFile(File cFile)
sends a file to the client.
void
setCookie(String name, String value, String path, Date expires)
sets a cookie
void
setHeaderLine(ProtocolResponseHeader header, String value)
sets one particular header line
void
setStatus(int statusCode)
sets the status of the response to a certain HTTP status code

Constructor Details

Response

public Response(int statusCode,
                Protocol protocol,
                OutputStream out,
                Request masterRequest)

Method Details

CRLF

public byte[] CRLF()

publishHeader

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

sendCookie15DG

public void sendCookie15DG(String name,
                           String value)
sets a fifteen day cookie
Parameters:
name - the field name
value - the field value

sendFile

public void sendFile(File cFile)
            throws Exception
sends a file to the client. Sets the MIME type accordingly
Parameters:
cFile - the file to send

setCookie

public void setCookie(String name,
                      String value,
                      String path,
                      Date expires)
sets a cookie
Parameters:
name - the field name
value - the field vaLUE
path - the relevant path
expires - the cookie activation day

setHeaderLine

public void setHeaderLine(ProtocolResponseHeader header,
                          String value)
sets one particular header line
Parameters:
header -
value -

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