ehcache

net.sf.ehcache.constructs.web
Class PageInfo

java.lang.Object
  extended by net.sf.ehcache.constructs.web.PageInfo
All Implemented Interfaces:
java.io.Serializable

public class PageInfo
extends java.lang.Object
implements java.io.Serializable

A Serializable representation of a HttpServletResponse.

Version:
$Id: PageInfo.java 606 2008-05-02 23:22:40Z gregluck $
Author:
Adam Murdoch, Greg Luck
See Also:
Serialized Form

Constructor Summary
PageInfo(int statusCode, java.lang.String contentType, java.util.Collection headers, java.util.Collection cookies, byte[] body, boolean storeGzipped)
          Creates a PageInfo.
 
Method Summary
 java.lang.String getContentType()
           
 byte[] getGzippedBody()
           
 java.util.List getHeaders()
          Returns the headers of the response.
 java.util.List getSerializableCookies()
          Returns the cookies of the response.
 int getStatusCode()
          Returns the status code of the response.
 byte[] getUngzippedBody()
           
 boolean hasGzippedBody()
           
 boolean hasUngzippedBody()
           
static boolean isGzipped(byte[] candidate)
          Checks the first two bytes of the candidate byte array for the magic number 0x677a.
 boolean isOk()
          Returns true if the response is Ok.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PageInfo

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

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

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

getContentType

public java.lang.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 java.util.List getHeaders()
Returns the headers of the response.


getSerializableCookies

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


getStatusCode

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


getUngzippedBody

public byte[] getUngzippedBody()
                        throws java.io.IOException
Returns:
the ungzipped version of the body. This gunzipped on demand when storedGzipped, otherwise the ungzipped body is returned.
Throws:
java.io.IOException

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

isOk

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

Returns:
true if the response code is 200.

ehcache