Package kong.unirest.core
Class Cookie
java.lang.Object
kong.unirest.core.Cookie
Represents a cookie parsed from the set-cookie header
per https://tools.ietf.org/html/rfc6265
note that the RFC is awful.
The wikipedia article is far easier to understand https://en.wikipedia.org/wiki/HTTP_cookie
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
Per Wikipedia: The Expires attribute defines a specific date and time for when the browser should delete the cookie.int
Per Wikipedia: the Max-Age attribute can be used to set the cookie's expiration as an interval of seconds in the future, relative to the time the browser received the cookie.getName()
getPath()
returns the SameSite attributegetValue()
boolean
Per Wikipedia: The HttpOnly attribute directs browsers not to expose cookies through channels other than HTTP (and HTTPS) requests.boolean
boolean
isSecure()
Per Wikipedia: The Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections.private void
parseExpires
(String text) private void
parseSection
(String[] sub) void
void
setHttpOnly
(boolean httpOnly) void
setPartitioned
(boolean partitionedFlag) void
void
setSecured
(boolean secureFlag) private String
stripQuoteWrapper
(String sub) toString()
-
Field Details
-
name
-
value
-
domain
-
path
-
httpOnly
private boolean httpOnly -
maxAge
-
expires
-
secure
private boolean secure -
sameSite
-
partitioned
private boolean partitioned
-
-
Constructor Details
-
Cookie
-
Cookie
Construct a cookie from a set-cookie value- Parameters:
v
- cookie string value
-
Cookie
-
-
Method Details
-
getDecode
-
stripQuoteWrapper
-
parseSection
-
parseExpires
-
toString
-
setDomain
-
setPath
-
setHttpOnly
public void setHttpOnly(boolean httpOnly) -
isPartitioned
public boolean isPartitioned() -
setPartitioned
public void setPartitioned(boolean partitionedFlag) -
setSecured
public void setSecured(boolean secureFlag) -
getName
- Returns:
- the cookie-name
-
getValue
- Returns:
- the cookie-value
-
getUrlDecodedValue
- Returns:
- the cookie-value, url-decoded
-
getDomain
- Returns:
- the domain value of the cookie
-
getPath
- Returns:
- the path value of the cookie
-
isHttpOnly
public boolean isHttpOnly()Per Wikipedia: The HttpOnly attribute directs browsers not to expose cookies through channels other than HTTP (and HTTPS) requests. This means that the cookie cannot be accessed via client-side scripting languages (notably JavaScript), and therefore cannot be stolen easily via cross-site scripting (a pervasive attack technique)- Returns:
- a boolean if the cookie is httpOnly
-
isSecure
public boolean isSecure()Per Wikipedia: The Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections.- Returns:
- a boolean of if the cookie is secure
-
getMaxAge
public int getMaxAge()Per Wikipedia: the Max-Age attribute can be used to set the cookie's expiration as an interval of seconds in the future, relative to the time the browser received the cookie.- Returns:
- Max-Age attribute
-
getExpiration
Per Wikipedia: The Expires attribute defines a specific date and time for when the browser should delete the cookie.- Returns:
- a ZonedDateTime of the expiration
-
getSameSite
returns the SameSite attribute- Returns:
- the SameSite attribute if set. or null
-