java.lang.Object
org.miaixz.bus.http.Cookie.Builder
- Enclosing class:
Cookie
A builder for creating
Cookie instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newCookieinstance.Sets the domain of the cookie, which will match the domain and its subdomains.expiresAt(long expiresAt) Sets the expiration time of the cookie.hostOnlyDomain(String domain) Sets the domain of the cookie to be host-only.httpOnly()Sets the cookie to be HTTP-only.Sets the name of the cookie.Sets the path of the cookie.secure()Sets the cookie to be secure (HTTPS only).Sets the value of the cookie.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
name
Sets the name of the cookie.- Parameters:
name- The cookie name.- Returns:
- this builder instance.
- Throws:
NullPointerException- if name is null.IllegalArgumentException- if name contains whitespace.
-
value
Sets the value of the cookie.- Parameters:
value- The cookie value.- Returns:
- this builder instance.
- Throws:
NullPointerException- if value is null.IllegalArgumentException- if value contains whitespace.
-
expiresAt
Sets the expiration time of the cookie.- Parameters:
expiresAt- The expiration time in milliseconds.- Returns:
- this builder instance.
-
domain
Sets the domain of the cookie, which will match the domain and its subdomains.- Parameters:
domain- The domain.- Returns:
- this builder instance.
- Throws:
NullPointerException- if domain is null.IllegalArgumentException- if the domain is invalid.
-
hostOnlyDomain
Sets the domain of the cookie to be host-only.- Parameters:
domain- The domain.- Returns:
- this builder instance.
- Throws:
NullPointerException- if domain is null.IllegalArgumentException- if the domain is invalid.
-
path
Sets the path of the cookie.- Parameters:
path- The path.- Returns:
- this builder instance.
- Throws:
IllegalArgumentException- if the path does not start with "/".
-
secure
Sets the cookie to be secure (HTTPS only).- Returns:
- this builder instance.
-
httpOnly
Sets the cookie to be HTTP-only.- Returns:
- this builder instance.
-
build
Builds a newCookieinstance.- Returns:
- a new
Cookieinstance. - Throws:
NullPointerException- if name, value, or domain is not set.
-