Interface HttpCookie
- All Known Implementing Classes:
 HttpCookie.Immutable, HttpCookie.JavaNetHttpCookie, HttpCookie.Wrapper, Response.HttpCookieFacade, Response.HttpCookieFacade
public interface HttpCookie
Implementation of RFC6265 HTTP Cookies (with fallback support for RFC2965).
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA builder forHttpCookieinstances.static classImmutable implementation ofHttpCookie.static classAHttpCookiethat wraps aHttpCookie.static enumThe possible values for theSameSiteattribute, defined in the follow-up of RFC 6265, at the time of this writing defined at RFC 6265bis.static classA wrapper forHttpCookieinstances. - 
Field Summary
Fields - 
Method Summary
Modifier and TypeMethodDescriptionstatic HttpCookieasJavaNetHttpCookie(HttpCookie httpCookie) Converts aHttpCookieto aHttpCookie.static HttpCookie.BuilderCreates aHttpCookie.Builderto build aHttpCookie.static HttpCookie.BuilderCreates aHttpCookie.Builderto build aHttpCookie.static HttpCookie.Builderbuild(HttpCookie httpCookie) Creates aHttpCookie.Builderto build aHttpCookie.static HttpCookie.Builderbuild(HttpCookie httpCookie) Creates aHttpCookie.Builderto build aHttpCookie.booleanstatic booleanequals(HttpCookie cookie1, Object obj) Implementation ofObject.equals(Object)compatible with RFC 6265.static StringformatExpires(Instant expires) Formats theInstantassociated with theExpiresattribute into a RFC 1123 string.static HttpCookieCreates a newHttpCookiefrom the given name and value.static HttpCookieCreates a newHttpCookiefrom the given name, value, version and attributes.static HttpCookieCreates a newHttpCookiefrom the given name, value and attributes.static HttpCookiefrom(HttpCookie httpCookie) Creates a newHttpCookiecopied from the givenHttpCookie.static HttpCookiefrom(HttpCookie cookie, String... additionalAttributes) default StringEquivalent togetAttributes().get(COMMENT_ATTRIBUTE).default StringEquivalent togetAttributes().get(DOMAIN_ATTRIBUTE).default Instantdefault longgetName()default StringgetPath()Equivalent togetAttributes().get(PATH_ATTRIBUTE).default HttpCookie.SameSitegetValue()intinthashCode()static inthashCode(HttpCookie httpCookie) Implementation ofObject.hashCode()compatible with RFC 6265.default booleandefault booleandefault booleandefault booleanisSecure()static InstantparseExpires(String expires) Parses theExpiresDate/Time attribute value into anInstant.static StringtoString(HttpCookie httpCookie) Formats this cookie into a string suitable to be used for logging. 
- 
Field Details
- 
COMMENT_ATTRIBUTE
- See Also:
 
 - 
DOMAIN_ATTRIBUTE
- See Also:
 
 - 
EXPIRES_ATTRIBUTE
- See Also:
 
 - 
HTTP_ONLY_ATTRIBUTE
- See Also:
 
 - 
MAX_AGE_ATTRIBUTE
- See Also:
 
 - 
PATH_ATTRIBUTE
- See Also:
 
 - 
SAME_SITE_ATTRIBUTE
- See Also:
 
 - 
SECURE_ATTRIBUTE
- See Also:
 
 - 
PARTITIONED_ATTRIBUTE
- See Also:
 
 
 - 
 - 
Method Details
- 
getName
String getName()- Returns:
 - the cookie name
 
 - 
getValue
String getValue()- Returns:
 - the cookie value
 
 - 
getVersion
int getVersion()- Returns:
 - the value of the 
Versionattribute 
 - 
getAttributes
 - 
getExpires
- Returns:
 - the value of the 
Expiresattribute, ornullif not present - See Also:
 
 - 
getMaxAge
default long getMaxAge()- Returns:
 - the value of the 
Max-Ageattribute, in seconds, or-1if not present - See Also:
 
 - 
isExpired
default boolean isExpired()- Returns:
 - whether the cookie is expired
 
 - 
getComment
Equivalent to
getAttributes().get(COMMENT_ATTRIBUTE).- Returns:
 - the value of the 
Commentattribute - See Also:
 
 - 
getDomain
Equivalent to
getAttributes().get(DOMAIN_ATTRIBUTE).- Returns:
 - the value of the 
Domainattribute - See Also:
 
 - 
getPath
Equivalent to
getAttributes().get(PATH_ATTRIBUTE).- Returns:
 - the value of the 
Pathattribute - See Also:
 
 - 
isSecure
default boolean isSecure()- Returns:
 - whether the 
Secureattribute is present - See Also:
 
 - 
getSameSite
- Returns:
 - the value of the 
SameSiteattribute - See Also:
 
 - 
isHttpOnly
default boolean isHttpOnly()- Returns:
 - whether the 
HttpOnlyattribute is present - See Also:
 
 - 
isPartitioned
default boolean isPartitioned()- Returns:
 - whether the 
Partitionedattribute is present - See Also:
 
 - 
hashCode
 - 
equals
 - 
from
Creates a newHttpCookiefrom the given name and value.- Parameters:
 name- the name of the cookievalue- the value of the cookie
 - 
from
Creates a newHttpCookiefrom the given name, value and attributes.- Parameters:
 name- the name of the cookievalue- the value of the cookieattributes- the map of attributes to use with this cookie (this map is used for field values such asgetDomain(),getPath(),getMaxAge(),isHttpOnly(),isSecure(),isPartitioned(),getComment(), plus any newly defined attributes unknown to this code base.
 - 
from
Creates a newHttpCookiefrom the given name, value, version and attributes.- Parameters:
 name- the name of the cookievalue- the value of the cookieversion- the version of the cookie (only used in RFC2965 mode)attributes- the map of attributes to use with this cookie (this map is used for field values such asgetDomain(),getPath(),getMaxAge(),isHttpOnly(),isSecure(),isPartitioned(),getComment(), plus any newly defined attributes unknown to this code base.
 - 
from
- Parameters:
 cookie- A cookie to base the new cookie on.additionalAttributes- Additional name value pairs of strings to use as additional attributes- Returns:
 - A new cookie based on the passed cookie plus additional attributes.
 
 - 
from
Creates a newHttpCookiecopied from the givenHttpCookie.- Parameters:
 httpCookie- theHttpCookieinstance to copy- Returns:
 - a new 
HttpCookiecopied from theHttpCookie - See Also:
 
 - 
build
Creates aHttpCookie.Builderto build aHttpCookie.- Parameters:
 name- the cookie namevalue- the cookie value- Returns:
 - a new 
HttpCookie.Builderinitialized with the given values 
 - 
build
Creates aHttpCookie.Builderto build aHttpCookie.- Parameters:
 name- the cookie namevalue- the cookie valueversion- the cookie version- Returns:
 - a new 
HttpCookie.Builderinitialized with the given values 
 - 
build
Creates aHttpCookie.Builderto build aHttpCookie.- Parameters:
 httpCookie- the cookie to copy- Returns:
 - a new 
HttpCookie.Builderinitialized with the given cookie 
 - 
build
Creates aHttpCookie.Builderto build aHttpCookie.- Parameters:
 httpCookie- theHttpCookieto copy- Returns:
 - a new 
HttpCookie.Builderinitialized with the given cookie 
 - 
asJavaNetHttpCookie
Converts aHttpCookieto aHttpCookie.- Parameters:
 httpCookie- the cookie to convert- Returns:
 - a new 
HttpCookie - See Also:
 
 - 
hashCode
Implementation of
Object.hashCode()compatible with RFC 6265.- Parameters:
 httpCookie- the cookie to be hashed- Returns:
 - the hash code of the cookie
 - See Also:
 
 - 
equals
Implementation of
Object.equals(Object)compatible with RFC 6265.Two cookies are equal if they have the same name (case-sensitive), the same domain (case-insensitive) and the same path (case-sensitive).
- Parameters:
 cookie1- the first cookie to equalobj- the second cookie to equal- Returns:
 - whether the cookies are equal
 - See Also:
 
 - 
toString
Formats this cookie into a string suitable to be used for logging.
- Parameters:
 httpCookie- the cookie to format- Returns:
 - a logging string representation of the cookie
 
 - 
formatExpires
 - 
parseExpires
 
 -