Package io.servicetalk.http.api
Class DefaultHttpSetCookie
- java.lang.Object
-
- io.servicetalk.http.api.DefaultHttpSetCookie
-
- All Implemented Interfaces:
HttpCookiePair,HttpSetCookie
public final class DefaultHttpSetCookie extends java.lang.Object implements HttpSetCookie
Default implementation ofHttpSetCookie.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.servicetalk.http.api.HttpSetCookie
HttpSetCookie.SameSite
-
-
Constructor Summary
Constructors Constructor Description DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)Create a new not wrapped, not secure and not HTTP-onlyHttpSetCookieinstance, with no path, domain, expire date and maximum age.DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value, boolean wrapped, boolean secure, boolean httpOnly)Create a newHttpSetCookieinstance, with no path, domain, expire date and maximum age.DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value, java.lang.CharSequence path, java.lang.CharSequence domain, java.lang.CharSequence expires, java.lang.Long maxAge, HttpSetCookie.SameSite sameSite, boolean wrapped, boolean secure, boolean httpOnly)Creates a newHttpSetCookieinstance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.CharSequencedomain()Returns the domain of thisHttpSetCookie.java.lang.CharSequenceencoded()Get the encoded value of thisHttpCookiePair.booleanequals(java.lang.Object o)java.lang.CharSequenceexpires()Returns the expire date of thisHttpSetCookieaccording to Expires.inthashCode()booleanisHttpOnly()Checks to see if thisHttpSetCookiecan only be accessed via HTTP.booleanisSecure()Checks to see if thisHttpSetCookieis secure.booleanisWrapped()Returnstrueif the value should be wrapped in DQUOTE as described in cookie-value.java.lang.LongmaxAge()Returns the maximum age of thisHttpSetCookiein seconds if specified.java.lang.CharSequencename()Returns the name of thisHttpCookiePair.static HttpSetCookieparseSetCookie(java.lang.CharSequence setCookieString, boolean validateContent)java.lang.CharSequencepath()Returns the path of thisHttpSetCookie.HttpSetCookie.SameSitesameSite()Get the value for the SameSite attribute.java.lang.StringtoString()java.lang.CharSequencevalue()Returns the value of thisHttpCookiePair.
-
-
-
Constructor Detail
-
DefaultHttpSetCookie
public DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)Create a new not wrapped, not secure and not HTTP-onlyHttpSetCookieinstance, with no path, domain, expire date and maximum age.- Parameters:
name- the cookie-name.value- the cookie-value.
-
DefaultHttpSetCookie
public DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value, boolean wrapped, boolean secure, boolean httpOnly)Create a newHttpSetCookieinstance, with no path, domain, expire date and maximum age.- Parameters:
name- the cookie-name.value- the cookie-value.wrapped-trueif the value should be wrapped in DQUOTE as described in cookie-value.secure- the secure-av.httpOnly- the httponly-av (see HTTP-only).
-
DefaultHttpSetCookie
public DefaultHttpSetCookie(java.lang.CharSequence name, java.lang.CharSequence value, @Nullable java.lang.CharSequence path, @Nullable java.lang.CharSequence domain, @Nullable java.lang.CharSequence expires, @Nullable java.lang.Long maxAge, @Nullable HttpSetCookie.SameSite sameSite, boolean wrapped, boolean secure, boolean httpOnly)Creates a newHttpSetCookieinstance.- Parameters:
name- the cookie-name.value- the cookie-value.path- the path-value.domain- the domain-value.expires- the expires-av. Represented as an RFC-1123 date defined in RFC-2616, Section 3.3.1.maxAge- the max-age-av.wrapped-trueif the value should be wrapped in DQUOTE as described in cookie-value.secure- the secure-av.httpOnly- the httponly-av (see HTTP-only).sameSite- the SameSite attribute.
-
-
Method Detail
-
parseSetCookie
public static HttpSetCookie parseSetCookie(java.lang.CharSequence setCookieString, boolean validateContent)
- Parameters:
setCookieString- The set-cookie-string value.validateContent-trueto make a best effort to validate the contents of the SetCookie.- Returns:
- a
HttpSetCookierepresentation ofsetCookie.
-
name
public java.lang.CharSequence name()
Description copied from interface:HttpCookiePairReturns the name of thisHttpCookiePair.- Specified by:
namein interfaceHttpCookiePair- Returns:
- The name of this
HttpCookiePair
-
value
public java.lang.CharSequence value()
Description copied from interface:HttpCookiePairReturns the value of thisHttpCookiePair.- Specified by:
valuein interfaceHttpCookiePair- Returns:
- The value of this
HttpCookiePair
-
isWrapped
public boolean isWrapped()
Description copied from interface:HttpCookiePairReturnstrueif the value should be wrapped in DQUOTE as described in cookie-value.- Specified by:
isWrappedin interfaceHttpCookiePair- Returns:
trueif the value should be wrapped in DQUOTE as described in cookie-value.
-
domain
@Nullable public java.lang.CharSequence domain()
Description copied from interface:HttpSetCookieReturns the domain of thisHttpSetCookie.- Specified by:
domainin interfaceHttpSetCookie- Returns:
- The domain of this
HttpSetCookie
-
path
@Nullable public java.lang.CharSequence path()
Description copied from interface:HttpSetCookieReturns the path of thisHttpSetCookie.- Specified by:
pathin interfaceHttpSetCookie- Returns:
- The
HttpSetCookie's path
-
maxAge
@Nullable public java.lang.Long maxAge()
Description copied from interface:HttpSetCookieReturns the maximum age of thisHttpSetCookiein seconds if specified.- Specified by:
maxAgein interfaceHttpSetCookie- Returns:
- The maximum age of this
HttpSetCookie.nullif none specified.
-
expires
@Nullable public java.lang.CharSequence expires()
Description copied from interface:HttpSetCookieReturns the expire date of thisHttpSetCookieaccording to Expires.- Specified by:
expiresin interfaceHttpSetCookie- Returns:
- the expire date of this
HttpSetCookieaccording to Expires.
-
sameSite
@Nullable public HttpSetCookie.SameSite sameSite()
Description copied from interface:HttpSetCookieGet the value for the SameSite attribute.- Specified by:
sameSitein interfaceHttpSetCookie- Returns:
- The value for the SameSite attribute.
-
isSecure
public boolean isSecure()
Description copied from interface:HttpSetCookieChecks to see if thisHttpSetCookieis secure.- Specified by:
isSecurein interfaceHttpSetCookie- Returns:
- True if this
HttpSetCookieis secure, otherwise false
-
isHttpOnly
public boolean isHttpOnly()
Description copied from interface:HttpSetCookieChecks to see if thisHttpSetCookiecan only be accessed via HTTP. If this returns true, theHttpSetCookiecannot be accessed through client side script - But only if the browser supports it. For more information, please look here- Specified by:
isHttpOnlyin interfaceHttpSetCookie- Returns:
- True if this
HttpSetCookieis HTTP-only or false if it isn't
-
encoded
public java.lang.CharSequence encoded()
Description copied from interface:HttpCookiePairGet the encoded value of thisHttpCookiePair.- Specified by:
encodedin interfaceHttpCookiePair- Returns:
- the encoded value of this
HttpCookiePair.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-