EAF 7.4 Implementation

com.lutris.http
Class HttpCookieParser

java.lang.Object
  extended by com.lutris.http.HttpCookieParser

public class HttpCookieParser
extends java.lang.Object

This class takes a cookie header and converts it into a set of http cookies. It can be used to parse request and response cookie headers as well as format response cookies.

Since:
Harmony1.0
Version:
$Revision: 1.2 $
Author:
Kyle Clark

Constructor Summary
HttpCookieParser()
           
 
Method Summary
static int expiresToMaxAge(java.lang.String dateStr)
          Convert an old cookie expires data to maximum age; assuming now as the start.
static java.lang.String formatResponseCookie(javax.servlet.http.Cookie cookie)
          Format a Cookie for a response header.
static java.lang.String maxAgeToExpires(int maxAge)
          Convert amaximum age to a old cookie expires data; assuming now as the start.
static javax.servlet.http.Cookie parseCookieString(java.lang.String cookieString)
           
static java.util.Vector parseRequestHeader(java.lang.String httpReqCookieHeader)
          Parses an http cookie request header and returns a vector of Cookie objects defined in the header.
static javax.servlet.http.Cookie parseRequestHeader(java.lang.String httpReqCookieHeader, java.lang.String name)
          Parses an http cookie request header and returns the first cookie that matches the specified name.
static java.util.Vector parseResponseHeader(java.lang.String httpResponseCookieHeader)
          Parses an http cookie response header and returns a vector of Cookie objects defined in the header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpCookieParser

public HttpCookieParser()
Method Detail

parseRequestHeader

public static java.util.Vector parseRequestHeader(java.lang.String httpReqCookieHeader)
Parses an http cookie request header and returns a vector of Cookie objects defined in the header. This method should only be used with the request cookie header "Cookie:".

Parameters:
httpReqCookieHeader - The http cookie request header to parse.
Returns:
vector containing the cookies defined in the header.

parseRequestHeader

public static javax.servlet.http.Cookie parseRequestHeader(java.lang.String httpReqCookieHeader,
                                                           java.lang.String name)
Parses an http cookie request header and returns the first cookie that matches the specified name. This method should only be used with the request cookie header "Cookie:".

Parameters:
httpReqCookieHeader - The http cookie request header to parse.
name - The cookie name of interest.
Returns:
The first cookie that matches. null if no matching cookies are found.

expiresToMaxAge

public static int expiresToMaxAge(java.lang.String dateStr)
Convert an old cookie expires data to maximum age; assuming now as the start.

Parameters:
dateStr - The string expiry date.
Returns:
The max age, in seconds.

maxAgeToExpires

public static java.lang.String maxAgeToExpires(int maxAge)
Convert amaximum age to a old cookie expires data; assuming now as the start.

Parameters:
The - max age, in seconds.
Returns:
The string expiry date.

parseResponseHeader

public static java.util.Vector parseResponseHeader(java.lang.String httpResponseCookieHeader)
Parses an http cookie response header and returns a vector of Cookie objects defined in the header. This method only works with http response headers, (i.e. Set-Cookie).

Parameters:
httpResponseCookieHeader - The http cookie response header from which the cookies are constructed.
Returns:
Vector containing the cookies defined in the header.

parseCookieString

public static javax.servlet.http.Cookie parseCookieString(java.lang.String cookieString)

formatResponseCookie

public static java.lang.String formatResponseCookie(javax.servlet.http.Cookie cookie)
Format a Cookie for a response header.

Parameters:
The - cookie to format.
Returns:
The value for the header (name is not included).

EAF 7.4 Implementation