Class DefaultCookie
java.lang.Object
io.netty.handler.codec.http.cookie.DefaultCookie
- Direct Known Subclasses:
DefaultCookie
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate java.lang.Stringprivate booleanprivate longprivate final java.lang.Stringprivate booleanprivate java.lang.Stringprivate CookieHeaderNames.SameSiteprivate booleanprivate java.lang.Stringprivate booleanFields inherited from interface Cookie
UNDEFINED_MAX_AGE -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCookie(java.lang.String name, java.lang.String value) Creates a new cookie with the specified name and value. -
Method Summary
Modifier and TypeMethodDescriptionintjava.lang.Stringdomain()Returns the domain of thisCookie.booleanequals(java.lang.Object o) inthashCode()booleanChecks to see if thisCookiecan only be accessed via HTTP.booleanChecks to see if thisCookieis partitionedbooleanisSecure()Checks to see if thisCookieis securelongmaxAge()Returns the maximum age of thisCookiein seconds orCookie.UNDEFINED_MAX_AGEif unspecifiedjava.lang.Stringname()Returns the name of thisCookie.java.lang.Stringpath()Returns the path of thisCookie.sameSite()Checks to see if thisCookiecan be sent along cross-site requests.voidsetDomain(java.lang.String domain) Sets the domain of thisCookie.voidsetHttpOnly(boolean httpOnly) Determines if thisCookieis HTTP only.voidsetMaxAge(long maxAge) Sets the maximum age of thisCookiein seconds.voidsetPartitioned(boolean partitioned) Sets thePartitionedattribute of thisCookievoidsetPath(java.lang.String path) Sets the path of thisCookie.voidsetSameSite(CookieHeaderNames.SameSite sameSite) Determines if this thisCookiecan be sent along cross-site requests.voidsetSecure(boolean secure) Sets the security getStatus of thisCookievoidsetValue(java.lang.String value) Sets the value of thisCookie.voidsetWrap(boolean wrap) Sets true if the value of thisCookieis to be wrapped with double quotes.java.lang.StringtoString()protected java.lang.StringvalidateValue(java.lang.String name, java.lang.String value) Deprecated.CookieUtil is package private, will be removed once old Cookie API is droppedjava.lang.Stringvalue()Returns the value of thisCookie.booleanwrap()Returns true if the raw value of thisCookie, was wrapped with double quotes in original Set-Cookie header.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
name
private final java.lang.String name -
value
private java.lang.String value -
wrap
private boolean wrap -
domain
private java.lang.String domain -
path
private java.lang.String path -
maxAge
private long maxAge -
secure
private boolean secure -
httpOnly
private boolean httpOnly -
sameSite
-
partitioned
private boolean partitioned
-
-
Constructor Details
-
DefaultCookie
public DefaultCookie(java.lang.String name, java.lang.String value) Creates a new cookie with the specified name and value.
-
-
Method Details
-
name
-
value
-
setValue
-
wrap
-
setWrap
-
domain
-
setDomain
-
path
-
setPath
-
maxAge
-
setMaxAge
public void setMaxAge(long maxAge) Description copied from interface:CookieSets the maximum age of thisCookiein seconds. If an age of0is specified, thisCookiewill be automatically removed by browser because it will expire immediately. IfCookie.UNDEFINED_MAX_AGEis specified, thisCookiewill be removed when the browser is closed. -
isSecure
-
setSecure
-
isHttpOnly
public boolean isHttpOnly()Description copied from interface:CookieChecks to see if thisCookiecan only be accessed via HTTP. If this returns true, theCookiecannot be accessed through client side script - But only if the browser supports it. For more information, please look here- Specified by:
isHttpOnlyin interfaceCookie- Returns:
- True if this
Cookieis HTTP-only or false if it isn't
-
setHttpOnly
public void setHttpOnly(boolean httpOnly) Description copied from interface:CookieDetermines if thisCookieis HTTP only. If set to true, thisCookiecannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.- Specified by:
setHttpOnlyin interfaceCookie- Parameters:
httpOnly- True if theCookieis HTTP only, otherwise false.
-
sameSite
-
setSameSite
-
isPartitioned
-
setPartitioned
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o) - Overrides:
equalsin classjava.lang.Object
-
compareTo
-
validateValue
@Deprecated protected java.lang.String validateValue(java.lang.String name, java.lang.String value) Deprecated.CookieUtil is package private, will be removed once old Cookie API is droppedValidate a cookie attribute value, throws aIllegalArgumentExceptionotherwise. Only intended to be used byDefaultCookie.- Parameters:
name- attribute namevalue- attribute value- Returns:
- the trimmed, validated attribute value
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-