Class BasicClientCookie
- All Implemented Interfaces:
Serializable
,Cloneable
,Cookie
,SetCookie
SetCookie
.- Since:
- 4.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionCookie attributes as specified by the origin serverprivate String
Domain attribute.private Instant
ExpirationInstant
.private String
Path attribute.private Instant
private boolean
ThehttpOnly
flag.private boolean
My secure flag.private final String
Cookie nameprivate static final long
private String
Cookie valueFields inherited from interface org.apache.hc.client5.http.cookie.Cookie
DOMAIN_ATTR, EXPIRES_ATTR, HTTP_ONLY_ATTR, MAX_AGE_ATTR, PATH_ATTR, SECURE_ATTR
-
Constructor Summary
ConstructorsConstructorDescriptionBasicClientCookie
(String name, String value) Default Constructor taking a name and a value. -
Method Summary
Modifier and TypeMethodDescriptionclone()
boolean
containsAttribute
(String name) getAttribute
(String name) Deprecated.Returns creation time of the cookie.Returns domain attribute of the cookie.Deprecated.Returns the expirationInstant
of the cookie, ornull
if none exists.getName()
Returns the name.getPath()
Returns the path attribute of the cookiegetValue()
Returns the value.boolean
Returns true if this cookie has expired.boolean
Deprecated.boolean
Checks whether this Cookie has been marked ashttpOnly
.boolean
Returnsfalse
if the cookie should be discarded at the end of the "session";true
otherwise.boolean
isSecure()
Indicates whether this cookie requires a secure connection.boolean
removeAttribute
(String name) void
setAttribute
(String name, String value) void
setCreationDate
(Instant creationDate) void
setCreationDate
(Date creationDate) Deprecated.void
Sets the domain attribute.void
setExpiryDate
(Instant expiryInstant) Sets expiration date.void
setExpiryDate
(Date expiryDate) Deprecated.Use {setExpiryDate(Instant)
}void
setHttpOnly
(boolean httpOnly) Sets the http-only attribute of the cookie.void
Sets the path attribute.void
setSecure
(boolean secure) Sets the secure attribute of the cookie.void
Sets the valuetoString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
name
Cookie name -
attribs
Cookie attributes as specified by the origin server -
value
Cookie value -
cookieDomain
Domain attribute. -
cookieExpiryDate
ExpirationInstant
. -
cookiePath
Path attribute. -
isSecure
private boolean isSecureMy secure flag. -
creationDate
-
httpOnly
private boolean httpOnlyThehttpOnly
flag.
-
-
Constructor Details
-
BasicClientCookie
Default Constructor taking a name and a value. The value may be null.- Parameters:
name
- The name.value
- The value.
-
-
Method Details
-
getName
Returns the name. -
getValue
Returns the value. -
setValue
Sets the value -
getExpiryDate
Deprecated.Returns the expirationDate
of the cookie, ornull
if none exists.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Specified by:
getExpiryDate
in interfaceCookie
- Returns:
- Expiration
Date
, ornull
. - See Also:
-
getExpiryInstant
Returns the expirationInstant
of the cookie, ornull
if none exists.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Specified by:
getExpiryInstant
in interfaceCookie
- Returns:
- Expiration
Instant
, ornull
.
-
setExpiryDate
Deprecated.Use {setExpiryDate(Instant)
}Sets expiration date.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Specified by:
setExpiryDate
in interfaceSetCookie
- Parameters:
expiryDate
- theDate
after which this cookie is no longer valid.- See Also:
-
setExpiryDate
Sets expiration date.Note: the object returned by this method is considered immutable. Changing it (e.g. using setTime()) could result in undefined behaviour. Do so at your peril.
- Specified by:
setExpiryDate
in interfaceSetCookie
- Parameters:
expiryInstant
- theInstant
after which this cookie is no longer valid.- Since:
- 5.2
- See Also:
-
isPersistent
public boolean isPersistent()Returnsfalse
if the cookie should be discarded at the end of the "session";true
otherwise.- Specified by:
isPersistent
in interfaceCookie
- Returns:
false
if the cookie should be discarded at the end of the "session";true
otherwise
-
getDomain
Returns domain attribute of the cookie. -
setDomain
Sets the domain attribute. -
getPath
Returns the path attribute of the cookie -
setPath
Sets the path attribute. -
isSecure
public boolean isSecure()Description copied from interface:Cookie
Indicates whether this cookie requires a secure connection. -
setSecure
public void setSecure(boolean secure) Sets the secure attribute of the cookie.When
true
the cookie should only be sent using a secure protocol (https). This should only be set when the cookie's originating server used a secure protocol to set the cookie's value. -
setHttpOnly
public void setHttpOnly(boolean httpOnly) Sets the http-only attribute of the cookie.- Specified by:
setHttpOnly
in interfaceSetCookie
- Parameters:
httpOnly
- true if this cookie is to be marked ashttpOnly
, false otherwise- Since:
- 5.2
-
isExpired
Deprecated.Returns true if this cookie has expired. -
isExpired
Returns true if this cookie has expired. -
getCreationDate
Deprecated.UsegetCreationInstant()
.Description copied from interface:Cookie
Returns creation time of the cookie.- Specified by:
getCreationDate
in interfaceCookie
- Since:
- 4.4
-
getCreationInstant
Description copied from interface:Cookie
Returns creation time of the cookie.- Specified by:
getCreationInstant
in interfaceCookie
- Since:
- 5.2
-
isHttpOnly
public boolean isHttpOnly()Description copied from interface:Cookie
Checks whether this Cookie has been marked ashttpOnly
.The default implementation returns
false
.- Specified by:
isHttpOnly
in interfaceCookie
- Returns:
- true if this Cookie has been marked as
httpOnly
, false otherwise - Since:
- 5.2
- See Also:
-
setCreationDate
Deprecated.- Since:
- 4.4
-
setCreationDate
- Since:
- 5.2
-
setAttribute
-
getAttribute
- Specified by:
getAttribute
in interfaceCookie
-
containsAttribute
- Specified by:
containsAttribute
in interfaceCookie
-
removeAttribute
- Since:
- 4.4
-
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
toString
-
getCreationInstant()
.