net.sf.ehcache.constructs.web

Class PageInfo

public class PageInfo extends Object implements Serializable

A Serializable representation of a HttpServletResponse.

Version: $Id: PageInfo.java 80 2006-05-14 03:16:22Z gregluck $

Author: Adam Murdoch Greg Luck

Constructor Summary
PageInfo(int statusCode, String contentType, Collection headers, Collection cookies, byte[] body, boolean storeGzipped)
Creates a PageInfo.
Method Summary
StringgetContentType()
byte[]getGzippedBody()
ListgetHeaders()
Returns the headers of the response.
ListgetSerializableCookies()
Returns the cookies of the response.
intgetStatusCode()
Returns the status code of the response.
byte[]getUngzippedBody()
booleanhasGzippedBody()
booleanhasUngzippedBody()
static booleanisGzipped(byte[] candidate)
Checks the first two bytes of the candidate byte array for the magic number 0x677a.
booleanisOk()
Returns true if the response is ok.

Constructor Detail

PageInfo

public PageInfo(int statusCode, String contentType, Collection headers, Collection cookies, byte[] body, boolean storeGzipped)
Creates a PageInfo.

Parameters: statusCode contentType headers cookies body storeGzipped set this to false for images and page fragments which should never be gzipped.

Method Detail

getContentType

public String getContentType()

Returns: the content type of the response.

getGzippedBody

public byte[] getGzippedBody()

Returns: the gzipped version of the body if the content is storeGzipped, otherwise null

getHeaders

public List getHeaders()
Returns the headers of the response.

getSerializableCookies

public List getSerializableCookies()
Returns the cookies of the response.

getStatusCode

public int getStatusCode()
Returns the status code of the response.

getUngzippedBody

public byte[] getUngzippedBody()

Returns: the ungzipped version of the body. This gunzipped on demand when storedGzipped, otherwise the ungzipped body is returned.

hasGzippedBody

public boolean hasGzippedBody()

Returns: true if there is a non null gzipped body

hasUngzippedBody

public boolean hasUngzippedBody()

Returns: true if there is a non null ungzipped body

isGzipped

public static boolean isGzipped(byte[] candidate)
Checks the first two bytes of the candidate byte array for the magic number 0x677a. This magic number was obtained from /usr/share/file/magic. The line for gzip is:

>>14 beshort 0x677a (gzipped)

Parameters: candidate the byte array to check

Returns: true if gzipped, false if null, less than two bytes or not gzipped

isOk

public boolean isOk()
Returns true if the response is ok.