Class DefaultCookie
- java.lang.Object
-
- io.netty.handler.codec.http.cookie.DefaultCookie
-
- Direct Known Subclasses:
DefaultCookie
public class DefaultCookie extends java.lang.Object implements Cookie
The defaultCookie
implementation.
-
-
Field Summary
-
Fields inherited from interface io.netty.handler.codec.http.cookie.Cookie
UNDEFINED_MAX_AGE
-
-
Constructor Summary
Constructors Constructor Description DefaultCookie(java.lang.String name, java.lang.String value)
Creates a new cookie with the specified name and value.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
compareTo(Cookie c)
java.lang.String
domain()
Returns the domain of thisCookie
.boolean
equals(java.lang.Object o)
int
hashCode()
boolean
isHttpOnly()
Checks to see if thisCookie
can only be accessed via HTTP.boolean
isPartitioned()
Checks to see if thisCookie
is partitionedboolean
isSecure()
Checks to see if thisCookie
is securelong
maxAge()
Returns the maximum age of thisCookie
in seconds orCookie.UNDEFINED_MAX_AGE
if unspecifiedjava.lang.String
name()
Returns the name of thisCookie
.java.lang.String
path()
Returns the path of thisCookie
.CookieHeaderNames.SameSite
sameSite()
Checks to see if thisCookie
can be sent along cross-site requests.void
setDomain(java.lang.String domain)
Sets the domain of thisCookie
.void
setHttpOnly(boolean httpOnly)
Determines if thisCookie
is HTTP only.void
setMaxAge(long maxAge)
Sets the maximum age of thisCookie
in seconds.void
setPartitioned(boolean partitioned)
Sets thePartitioned
attribute of thisCookie
void
setPath(java.lang.String path)
Sets the path of thisCookie
.void
setSameSite(CookieHeaderNames.SameSite sameSite)
Determines if this thisCookie
can be sent along cross-site requests.void
setSecure(boolean secure)
Sets the security getStatus of thisCookie
void
setValue(java.lang.String value)
Sets the value of thisCookie
.void
setWrap(boolean wrap)
Sets true if the value of thisCookie
is to be wrapped with double quotes.java.lang.String
toString()
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 droppedjava.lang.String
value()
Returns the value of thisCookie
.boolean
wrap()
Returns true if the raw value of thisCookie
, was wrapped with double quotes in original Set-Cookie header.
-
-
-
Method Detail
-
name
public java.lang.String name()
Description copied from interface:Cookie
Returns the name of thisCookie
.
-
value
public java.lang.String value()
Description copied from interface:Cookie
Returns the value of thisCookie
.
-
setValue
public void setValue(java.lang.String value)
Description copied from interface:Cookie
Sets the value of thisCookie
.
-
wrap
public boolean wrap()
Description copied from interface:Cookie
Returns true if the raw value of thisCookie
, was wrapped with double quotes in original Set-Cookie header.
-
setWrap
public void setWrap(boolean wrap)
Description copied from interface:Cookie
Sets true if the value of thisCookie
is to be wrapped with double quotes.
-
domain
public java.lang.String domain()
Description copied from interface:Cookie
Returns the domain of thisCookie
.
-
setDomain
public void setDomain(java.lang.String domain)
Description copied from interface:Cookie
Sets the domain of thisCookie
.
-
path
public java.lang.String path()
Description copied from interface:Cookie
Returns the path of thisCookie
.
-
setPath
public void setPath(java.lang.String path)
Description copied from interface:Cookie
Sets the path of thisCookie
.
-
maxAge
public long maxAge()
Description copied from interface:Cookie
Returns the maximum age of thisCookie
in seconds orCookie.UNDEFINED_MAX_AGE
if unspecified
-
setMaxAge
public void setMaxAge(long maxAge)
Description copied from interface:Cookie
Sets the maximum age of thisCookie
in seconds. If an age of0
is specified, thisCookie
will be automatically removed by browser because it will expire immediately. IfCookie.UNDEFINED_MAX_AGE
is specified, thisCookie
will be removed when the browser is closed.
-
isSecure
public boolean isSecure()
Description copied from interface:Cookie
Checks to see if thisCookie
is secure
-
setSecure
public void setSecure(boolean secure)
Description copied from interface:Cookie
Sets the security getStatus of thisCookie
-
isHttpOnly
public boolean isHttpOnly()
Description copied from interface:Cookie
Checks to see if thisCookie
can only be accessed via HTTP. If this returns true, theCookie
cannot be accessed through client side script - But only if the browser supports it. For more information, please look here- Specified by:
isHttpOnly
in interfaceCookie
- Returns:
- True if this
Cookie
is HTTP-only or false if it isn't
-
setHttpOnly
public void setHttpOnly(boolean httpOnly)
Description copied from interface:Cookie
Determines if thisCookie
is HTTP only. If set to true, thisCookie
cannot be accessed by a client side script. However, this works only if the browser supports it. For information, please look here.- Specified by:
setHttpOnly
in interfaceCookie
- Parameters:
httpOnly
- True if theCookie
is HTTP only, otherwise false.
-
sameSite
public CookieHeaderNames.SameSite sameSite()
Checks to see if thisCookie
can be sent along cross-site requests. For more information, please look here- Returns:
- same-site-flag value
-
setSameSite
public void setSameSite(CookieHeaderNames.SameSite sameSite)
Determines if this thisCookie
can be sent along cross-site requests. For more information, please look here- Parameters:
sameSite
- same-site-flag value
-
isPartitioned
public boolean isPartitioned()
Checks to see if thisCookie
is partitioned- Returns:
- True if this
Cookie
is partitioned, otherwise false
-
setPartitioned
public void setPartitioned(boolean partitioned)
Sets thePartitioned
attribute of thisCookie
- Parameters:
partitioned
- True if thisCookie
is to be partitioned, otherwise false
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(Cookie c)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Cookie>
-
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 aIllegalArgumentException
otherwise. 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:
toString
in classjava.lang.Object
-
-