org.apache.commons.httpclient.cookie
Interface CookieSpec

All Known Implementing Classes:
CookieSpecBase

public interface CookieSpec

Cookie management specification must define

for a given host, port and path of origin

Since:
2.0
Author:
Oleg Kalnichevski

Field Summary
static java.lang.String PATH_DELIM
          Path delimiter
static char PATH_DELIM_CHAR
          Path delimiting charachter
 
Method Summary
 java.lang.String formatCookie(Cookie cookie)
          Return a string suitable for sending in a "Cookie" header
 Header formatCookieHeader(Cookie cookie)
          Create a "Cookie" Header containing the Cookie.
 Header formatCookieHeader(Cookie[] cookies)
          Create a "Cookie" Header containing all Cookies in cookies.
 java.lang.String formatCookies(Cookie[] cookies)
          Create a "Cookie" header value containing all Cookies in cookies suitable for sending in a "Cookie" header
 boolean match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)
          Return true if the cookie should be submitted with a request with given attributes, false otherwise.
 Cookie[] match(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie[] cookies)
          Return an array of Cookies that should be submitted with a request with given attributes, false otherwise.
 Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, Header header)
          Parse the "Set-Cookie" Header into an array of Cookies.
 Cookie[] parse(java.lang.String host, int port, java.lang.String path, boolean secure, java.lang.String header)
          Parse the "Set-Cookie" header value into an array of Cookies.
 void parseAttribute(NameValuePair attribute, Cookie cookie)
          Parse the cookie attribute and update the corresponsing Cookie properties.
 void validate(java.lang.String host, int port, java.lang.String path, boolean secure, Cookie cookie)
          Perform Cookie validation accoding to validation rules defined by the cookie specification
 

Field Detail

PATH_DELIM

public static final java.lang.String PATH_DELIM
Path delimiter

See Also:
Constant Field Values

PATH_DELIM_CHAR

public static final char PATH_DELIM_CHAR
Path delimiting charachter

Method Detail

parse

public Cookie[] parse(java.lang.String host,
                      int port,
                      java.lang.String path,
                      boolean secure,
                      java.lang.String header)
               throws MalformedCookieException
Parse the "Set-Cookie" header value into an array of Cookies.

Parameters:
host - the host from which the Set-Cookie value was received
port - the port from which the Set-Cookie value was received
path - the path from which the Set-Cookie value was received
secure - true when the Set-Cookie value was received over secure conection
header - the Set-Cookie received from the server
Returns:
an array of Cookies parsed from the Set-Cookie value
Throws:
MalformedCookieException - if an exception occurs during parsing
java.lang.IllegalArgumentException - if an input parameter is illegal

parse

public Cookie[] parse(java.lang.String host,
                      int port,
                      java.lang.String path,
                      boolean secure,
                      Header header)
               throws MalformedCookieException
Parse the "Set-Cookie" Header into an array of Cookies.

Parameters:
host - the host from which the Set-Cookie header was received
port - the port from which the Set-Cookie header was received
path - the path from which the Set-Cookie header was received
secure - true when the Set-Cookie header was received over secure conection
header - the Set-Cookie received from the server
Returns:
an array of Cookies parsed from the "Set-Cookie" header
Throws:
MalformedCookieException - if an exception occurs during parsing
java.lang.IllegalArgumentException - if an input parameter is illegal

parseAttribute

public void parseAttribute(NameValuePair attribute,
                           Cookie cookie)
                    throws MalformedCookieException
Parse the cookie attribute and update the corresponsing Cookie properties.

Parameters:
attribute - NameValuePair cookie attribute from the Set-Cookie
cookie - Cookie to be updated
Throws:
MalformedCookieException - if an exception occurs during parsing
java.lang.IllegalArgumentException - if an input parameter is illegal

validate

public void validate(java.lang.String host,
                     int port,
                     java.lang.String path,
                     boolean secure,
                     Cookie cookie)
              throws MalformedCookieException
Perform Cookie validation accoding to validation rules defined by the cookie specification

Parameters:
host - the host from which the Cookie was received
port - the port from which the Cookie was received
path - the path from which the Cookie was received
secure - true when the Cookie was received using a secure connection
Throws:
MalformedCookieException - if an exception occurs during validation
java.lang.IllegalArgumentException - if an input parameter is illegal

match

public boolean match(java.lang.String host,
                     int port,
                     java.lang.String path,
                     boolean secure,
                     Cookie cookie)
Return true if the cookie should be submitted with a request with given attributes, false otherwise.

Parameters:
host - the host to which the request is being submitted
port - the port to which the request is being submitted
path - the path to which the request is being submitted
secure - true if the request is using a secure connection
Returns:
true if the cookie matches the criterium

match

public Cookie[] match(java.lang.String host,
                      int port,
                      java.lang.String path,
                      boolean secure,
                      Cookie[] cookies)
Return an array of Cookies that should be submitted with a request with given attributes, false otherwise.

Parameters:
host - the host to which the request is being submitted
port - the port to which the request is being submitted (currenlty ignored)
path - the path to which the request is being submitted
secure - true if the request is using a secure protocol
Returns:
an array of Cookies matching the criterium

formatCookie

public java.lang.String formatCookie(Cookie cookie)
Return a string suitable for sending in a "Cookie" header

Returns:
a string suitable for sending in a "Cookie" header.

formatCookies

public java.lang.String formatCookies(Cookie[] cookies)
Create a "Cookie" header value containing all Cookies in cookies suitable for sending in a "Cookie" header

Returns:
a string suitable for sending in a Cookie header.
Throws:
java.lang.IllegalArgumentException - if an input parameter is illegal

formatCookieHeader

public Header formatCookieHeader(Cookie[] cookies)
Create a "Cookie" Header containing all Cookies in cookies.

Returns:
a "Cookie" Header.
Throws:
java.lang.IllegalArgumentException - if an input parameter is illegal

formatCookieHeader

public Header formatCookieHeader(Cookie cookie)
Create a "Cookie" Header containing the Cookie.

Returns:
a Cookie header.
Throws:
java.lang.IllegalArgumentException - if an input parameter is illegal


Copyright © 2001-2003 Apache Software Foundation. All Rights Reserved.