Package org.apache.http.impl.cookie
Class RFC6265CookieSpec
- java.lang.Object
-
- org.apache.http.impl.cookie.RFC6265CookieSpec
-
- All Implemented Interfaces:
CookieSpec
- Direct Known Subclasses:
RFC6265CookieSpecBase
@Contract(threading=SAFE) public class RFC6265CookieSpec extends java.lang.Object implements CookieSpec
Cookie management functions shared by RFC C6265 compliant specification.- Since:
- 4.5
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,CookieAttributeHandler>attribHandlerMapprivate CookieAttributeHandler[]attribHandlersprivate static charCOMMA_CHARprivate static charDQUOTE_CHARprivate static charEQUAL_CHARprivate static charESCAPE_CHARprivate static charPARAM_DELIMITERprivate static java.util.BitSetSPECIAL_CHARSprivate static java.util.BitSetTOKEN_DELIMSprivate org.apache.http.message.TokenParsertokenParserprivate static java.util.BitSetVALUE_DELIMS
-
Constructor Summary
Constructors Modifier Constructor Description protectedRFC6265CookieSpec(CommonCookieAttributeHandler... handlers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleancontainsChars(java.lang.CharSequence s, java.util.BitSet chars)(package private) booleancontainsSpecialChar(java.lang.CharSequence s)java.util.List<org.apache.http.Header>formatCookies(java.util.List<Cookie> cookies)Create"Cookie"headers for an array of Cookies.(package private) static java.lang.StringgetDefaultDomain(CookieOrigin origin)(package private) static java.lang.StringgetDefaultPath(CookieOrigin origin)intgetVersion()Returns version of the state management this cookie specification conforms to.org.apache.http.HeadergetVersionHeader()Returns a request header identifying what version of the state management specification is understood.booleanmatch(Cookie cookie, CookieOrigin origin)Determines if a Cookie matches the target location.java.util.List<Cookie>parse(org.apache.http.Header header, CookieOrigin origin)Parse the"Set-Cookie"Header into an array of Cookies.voidvalidate(Cookie cookie, CookieOrigin origin)Validate the cookie according to validation rules defined by the cookie specification.
-
-
-
Field Detail
-
PARAM_DELIMITER
private static final char PARAM_DELIMITER
- See Also:
- Constant Field Values
-
COMMA_CHAR
private static final char COMMA_CHAR
- See Also:
- Constant Field Values
-
EQUAL_CHAR
private static final char EQUAL_CHAR
- See Also:
- Constant Field Values
-
DQUOTE_CHAR
private static final char DQUOTE_CHAR
- See Also:
- Constant Field Values
-
ESCAPE_CHAR
private static final char ESCAPE_CHAR
- See Also:
- Constant Field Values
-
TOKEN_DELIMS
private static final java.util.BitSet TOKEN_DELIMS
-
VALUE_DELIMS
private static final java.util.BitSet VALUE_DELIMS
-
SPECIAL_CHARS
private static final java.util.BitSet SPECIAL_CHARS
-
attribHandlers
private final CookieAttributeHandler[] attribHandlers
-
attribHandlerMap
private final java.util.Map<java.lang.String,CookieAttributeHandler> attribHandlerMap
-
tokenParser
private final org.apache.http.message.TokenParser tokenParser
-
-
Constructor Detail
-
RFC6265CookieSpec
protected RFC6265CookieSpec(CommonCookieAttributeHandler... handlers)
-
-
Method Detail
-
getDefaultPath
static java.lang.String getDefaultPath(CookieOrigin origin)
-
getDefaultDomain
static java.lang.String getDefaultDomain(CookieOrigin origin)
-
parse
public final java.util.List<Cookie> parse(org.apache.http.Header header, CookieOrigin origin) throws MalformedCookieException
Description copied from interface:CookieSpecParse the"Set-Cookie"Header into an array of Cookies.This method will not perform the validation of the resultant
Cookies- Specified by:
parsein interfaceCookieSpec- Parameters:
header- theSet-Cookiereceived from the serverorigin- details of the cookie origin- Returns:
- an array of
Cookies parsed from the header - Throws:
MalformedCookieException- if an exception occurs during parsing- See Also:
CookieSpec.validate(org.apache.http.cookie.Cookie, org.apache.http.cookie.CookieOrigin)
-
validate
public final void validate(Cookie cookie, CookieOrigin origin) throws MalformedCookieException
Description copied from interface:CookieSpecValidate the cookie according to validation rules defined by the cookie specification.- Specified by:
validatein interfaceCookieSpec- Parameters:
cookie- the Cookie to validateorigin- details of the cookie origin- Throws:
MalformedCookieException- if the cookie is invalid
-
match
public final boolean match(Cookie cookie, CookieOrigin origin)
Description copied from interface:CookieSpecDetermines if a Cookie matches the target location.- Specified by:
matchin interfaceCookieSpec- Parameters:
cookie- the Cookie to be matchedorigin- the target to test against- Returns:
trueif the cookie should be submitted with a request with given attributes,falseotherwise.
-
formatCookies
public java.util.List<org.apache.http.Header> formatCookies(java.util.List<Cookie> cookies)
Description copied from interface:CookieSpecCreate"Cookie"headers for an array of Cookies.- Specified by:
formatCookiesin interfaceCookieSpec- Parameters:
cookies- the Cookies format into a Cookie header- Returns:
- a Header for the given Cookies.
-
containsSpecialChar
boolean containsSpecialChar(java.lang.CharSequence s)
-
containsChars
boolean containsChars(java.lang.CharSequence s, java.util.BitSet chars)
-
getVersion
public final int getVersion()
Description copied from interface:CookieSpecReturns version of the state management this cookie specification conforms to.- Specified by:
getVersionin interfaceCookieSpec- Returns:
- version of the state management specification
-
getVersionHeader
public final org.apache.http.Header getVersionHeader()
Description copied from interface:CookieSpecReturns a request header identifying what version of the state management specification is understood. May benullif the cookie specification does not supportCookie2header.- Specified by:
getVersionHeaderin interfaceCookieSpec
-
-