Package org.apache.http.impl.cookie
Class RFC2965PortAttributeHandler
java.lang.Object
org.apache.http.impl.cookie.RFC2965PortAttributeHandler
- All Implemented Interfaces:
CommonCookieAttributeHandler
,CookieAttributeHandler
@Contract(threading=IMMUTABLE)
public class RFC2965PortAttributeHandler
extends Object
implements CommonCookieAttributeHandler
"Port"
cookie attribute handler for RFC 2965 cookie spec.- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
match
(Cookie cookie, CookieOrigin origin) Match cookie port attribute.void
Parse cookie port attribute.private static int[]
parsePortAttribute
(String portValue) Parses the given Port attribute value (e.g.private static boolean
portMatch
(int port, int[] ports) Returnstrue
if the given port exists in the given ports list.void
validate
(Cookie cookie, CookieOrigin origin) Validate cookie port attribute.
-
Constructor Details
-
RFC2965PortAttributeHandler
public RFC2965PortAttributeHandler()
-
-
Method Details
-
parsePortAttribute
Parses the given Port attribute value (e.g. "8000,8001,8002") into an array of ports.- Parameters:
portValue
- port attribute value- Returns:
- parsed array of ports
- Throws:
MalformedCookieException
- if there is a problem in parsing due to invalid portValue.
-
portMatch
private static boolean portMatch(int port, int[] ports) Returnstrue
if the given port exists in the given ports list.- Parameters:
port
- port of host where cookie was received from or being sent to.ports
- port list- Returns:
- true returns
true
if the given port exists in the given ports list;false
otherwise.
-
parse
Parse cookie port attribute.- Specified by:
parse
in interfaceCookieAttributeHandler
- Parameters:
cookie
-Cookie
to be updatedportValue
- cookie attribute value from the cookie response header- Throws:
MalformedCookieException
-
validate
Validate cookie port attribute. If the Port attribute was specified in header, the request port must be in cookie's port list.- Specified by:
validate
in interfaceCookieAttributeHandler
- Parameters:
cookie
-Cookie
to validateorigin
- the cookie source to validate against- Throws:
MalformedCookieException
- if cookie validation fails for this attribute
-
match
Match cookie port attribute. If the Port attribute is not specified in header, the cookie can be sent to any port. Otherwise, the request port must be in the cookie's port list.- Specified by:
match
in interfaceCookieAttributeHandler
- Parameters:
cookie
-Cookie
to matchorigin
- the cookie source to match against- Returns:
true
if the match is successful;false
otherwise
-
getAttributeName
- Specified by:
getAttributeName
in interfaceCommonCookieAttributeHandler
-