net.groboclown.util.http.v1
Class NetscapeCookieParser

java.lang.Object
  |
  +--net.groboclown.util.http.v1.NetscapeCookieParser
All Implemented Interfaces:
IHttpClientStateParser
Direct Known Subclasses:
Rfc2109CookieParser

public class NetscapeCookieParser
extends Object
implements IHttpClientStateParser

Parses cookies to and from the HTTP messages. Only parses out the Netscape values. The specification is archived at The Netscape Cookie Specification.

Future consideration: optimise the parseCookieNameValue in an OO way: create a base class which performs an action on the given Cookie object, and store these in a HashMap/Hashtable for faster processing.

Since:
Alpha 0.9.1
Version:
Alpha 0.9.1
Author:
Matt Albrecht

Inner Class Summary
protected static interface NetscapeCookieParser.ICookieValueParser
           
protected static class NetscapeCookieParser.NameValuePair
           
 
Field Summary
private static Hashtable NETSCAPE_COOKIE_VALUE_PARSERS
           
private static String SET_COOKIE_NAME
           
 
Constructor Summary
NetscapeCookieParser()
           
 
Method Summary
(package private) static void ()
           
protected  IHttpClientState[] abortWithCookies(Cookie finishedCookie, String header)
           
protected  NetscapeCookieParser.NameValuePair[] divideLineIntoNameValuePairs(String header)
          Split up the header into name-value pairs.
protected  NetscapeCookieParser.ICookieValueParser getCookieValueParser(NetscapeCookieParser.NameValuePair pair)
           
protected  String makeString(char[] buff, int startPos, int endPos)
           
 IHttpClientState[] parseClientStateHeaders(IHttpResponseMessage msg)
          Return the list of cookies that are contained in the headers for the message.
 IHttpClientState[] parseHeader(String header)
           
 IHttpClientState[] parseHeaders(String[] cookies)
          Return the list of cookies that are contained in the given header values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SET_COOKIE_NAME

private static final String SET_COOKIE_NAME

NETSCAPE_COOKIE_VALUE_PARSERS

private static final Hashtable NETSCAPE_COOKIE_VALUE_PARSERS
Constructor Detail

NetscapeCookieParser

public NetscapeCookieParser()
Method Detail

static void ()

parseClientStateHeaders

public IHttpClientState[] parseClientStateHeaders(IHttpResponseMessage msg)
Return the list of cookies that are contained in the headers for the message. If none of them are supported, returns null. This needs to be thread safe.
Specified by:
parseClientStateHeaders in interface IHttpClientStateParser

parseHeaders

public IHttpClientState[] parseHeaders(String[] cookies)
Return the list of cookies that are contained in the given header values. This needs to be thread safe.

parseHeader

public IHttpClientState[] parseHeader(String header)

divideLineIntoNameValuePairs

protected NetscapeCookieParser.NameValuePair[] divideLineIntoNameValuePairs(String header)
Split up the header into name-value pairs.

getCookieValueParser

protected NetscapeCookieParser.ICookieValueParser getCookieValueParser(NetscapeCookieParser.NameValuePair pair)

abortWithCookies

protected IHttpClientState[] abortWithCookies(Cookie finishedCookie,
                                              String header)

makeString

protected String makeString(char[] buff,
                            int startPos,
                            int endPos)


Written under the LGPL