java.lang.Object
org.miaixz.bus.http.Cookie
An RFC 6265-compliant HTTP cookie.
This class supports cookie creation, parsing, and matching. It does not support additional attributes like Chromium's Priority=HIGH extension.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondomain()Returns the domain of this cookie.booleanCompares this cookie to another object for equality.longReturns the expiration time of this cookie.inthashCode()Computes the hash code for this cookie.booleanhostOnly()Returnstrueif this cookie is host-only.booleanhttpOnly()Returnstrueif this cookie should only be sent over HTTP APIs.booleanReturnstrueif this cookie matches the given URL.name()Returns the name of this cookie.static CookieParses aSet-Cookieheader into aCookie.Parses allSet-Cookieheaders from an HTTP response.path()Returns the path of this cookie.booleanReturnstrueif this cookie is persistent.booleansecure()Returnstrueif this cookie should only be sent over HTTPS.toString()Returns the string representation of this cookie.value()Returns the value of this cookie.
-
Method Details
-
parse
Parses aSet-Cookieheader into aCookie.- Parameters:
url- The URL that sent this cookie.setCookie- TheSet-Cookieheader value.- Returns:
- The parsed cookie, or null if the cookie is invalid.
-
parseAll
Parses allSet-Cookieheaders from an HTTP response.- Parameters:
url- The URL that sent these cookies.headers- The response headers.- Returns:
- A list of parsed cookies.
-
name
Returns the name of this cookie.- Returns:
- The cookie name.
-
value
Returns the value of this cookie.- Returns:
- The cookie value.
-
persistent
public boolean persistent()Returnstrueif this cookie is persistent.- Returns:
trueif this cookie is persistent.
-
expiresAt
public long expiresAt()Returns the expiration time of this cookie.- Returns:
- The expiration time in milliseconds.
-
hostOnly
public boolean hostOnly()Returnstrueif this cookie is host-only.- Returns:
trueif this cookie is host-only.
-
domain
Returns the domain of this cookie.- Returns:
- The domain.
-
path
Returns the path of this cookie.- Returns:
- The path.
-
httpOnly
public boolean httpOnly()Returnstrueif this cookie should only be sent over HTTP APIs.- Returns:
trueif this cookie is HTTP-only.
-
secure
public boolean secure()Returnstrueif this cookie should only be sent over HTTPS.- Returns:
trueif this cookie is secure.
-
matches
Returnstrueif this cookie matches the given URL.- Parameters:
url- The URL to check.- Returns:
trueif this cookie matches the URL.
-
toString
Returns the string representation of this cookie. -
equals
Compares this cookie to another object for equality. -
hashCode
public int hashCode()Computes the hash code for this cookie.
-