Parses the Set-Cookie value into an array of Cookies.
Syntax of the Set-Cookie HTTP Response Header:
This is the format a CGI script would use to add to
the HTTP headers a new piece of data which is to be stored by
the client for later retrieval.
Set-Cookie: NAME=VALUE; expires=DATE; path=PATH; domain=DOMAIN_NAME; secure
Please note that Netscape draft specification does not fully
conform to the HTTP header format. Netscape draft does not specify
whether multiple cookies may be sent in one header. Hence, comma
character may be present in unquoted cookie value or unquoted
parameter value.
if (header == null) {
throw new IllegalArgumentException("Header may not be null");
}
if (origin == null) {
throw new IllegalArgumentException("Cookie origin may not be null");
}
NetscapeDraftHeaderParser parser = NetscapeDraftHeaderParser.DEFAULT;
CharArrayBuffer buffer;
ParserCursor cursor;
if (header instanceof FormattedHeader) {
buffer = ((FormattedHeader) header).getBuffer();
cursor = new ParserCursor(
((FormattedHeader) header).getValuePos(),
buffer.length());
} else {
String s = header.getValue();
if (s == null) {
throw new MalformedCookieException("Header value is null");
}
buffer = new CharArrayBuffer(s.length());
buffer.append(s);
cursor = new ParserCursor(0, buffer.length());
}
return parse(new HeaderElement[] { parser.parseHeader(buffer, cursor) }, origin);