public abstract class AbstractHeaderFields<C extends Cookie,T extends HeaderFields<C,T>> extends HashMap<String,List<String>> implements HeaderFields<C,T>
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
AbstractHeaderFields() |
AbstractHeaderFields(Map<String,List<String>> aFromHeaderFields) |
Modifier and Type | Method and Description |
---|---|
C |
addCookie(C aCookie)
Adds an individual server-side cookie to be sent to the client to this
ResponseHeaderFields instance. |
C |
addCookie(String aCookieName,
String aValue)
Adds an individual server-side cookie to be sent to the client to this
ResponseHeaderFields instance. |
void |
addTo(String aHeaderField,
String aValue)
Adds a value to the list of values associated with the given header field
(key),
|
protected abstract C |
createCookie(String aHttpCookie)
|
protected abstract C |
createCookie(String aCookieName,
String aValue)
Creates a plain
Cookie with the given name and value. |
List<String> |
get(Object aKey) |
List<C> |
getCookie(String aCookieName)
Retrieves an individual cookie sent by the client stored in this
RequestHeaderFields instance. |
protected abstract String |
getCookieFieldName()
The header field name for the
Cookie elements. |
List<C> |
getCookies()
Retrieves an array of cookies sent by the client stored in this
RequestHeaderFields instance. |
List<String> |
put(String key,
List<String> value) |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
finalize, getClass, notify, notifyAll, wait, wait, wait
addTo, getAcceptTypes, getAllows, getContentType, getCorrelationId, getFirst, getHost, getUserAgent, set, setAcceptTypes, setAllows, setContentType, setCorrelationId, setHost, setUserAgent, toHttpCookies, withAcceptTypes, withAddCookie, withAddCookie, withAddTo, withAllows, withContentType, withCorrelationId, withHost, withSet, withSet, withUserAgent
getFirst, set, withAddTo
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
public void addTo(String aHeaderField, String aValue)
HttpFields
addTo
in interface HttpFields<T extends HeaderFields<C,T>>
aHeaderField
- The header field (key) of which's list of values a value is
to be added.aValue
- The value to be added to the list of values associated to
the given header field (key).public C addCookie(C aCookie)
HeaderFields
ResponseHeaderFields
instance. The server-side cookies are
retrieved from the #HEADER_SET_FIELD_COOKIE
header field.
WITH THE METHOD HeaderFields.getCookies()
and HeaderFields.getCookie(String)
ONLY
THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED. (E.G. COOKIES RESIDING
IN THE HEADER FIELD #HEADER_FIELD_COOKIE). COOKIES SET VIA
HeaderFields.addCookie(String, String)
OR
HeaderFields.withAddCookie(String, String)
CANNOT BE RETRIEVED, AS THE
COOKIES BEING SET SERVER-SIDE ARE PUT IN THE #HEADER_FIELD_COOKIE
.addCookie
in interface HeaderFields<C extends Cookie,T extends HeaderFields<C,T>>
aCookie
- The cookie to be added.ResponseHeaderFields
instance!public List<C> getCookies()
HeaderFields
RequestHeaderFields
instance. If no cookie has been found, then
an empty array is returned. The client-side cookies are retrieved from
the #HEADER_FIELD_COOKIE
header field.
WITH THE METHOD HeaderFields.getCookies()
and HeaderFields.getCookie(String)
ONLY
THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED. (E.G. COOKIES RESIDING
IN THE HEADER FIELD #HEADER_FIELD_COOKIE). COOKIES SET VIA
HeaderFields.addCookie(String, String)
OR
HeaderFields.withAddCookie(String, String)
CANNOT BE RETRIEVED, AS THE
COOKIES BEING SET SERVER-SIDE ARE PUT IN THE #HEADER_FIELD_COOKIE
.
According to the Netscape cookie_spec
(https://curl.haxx.se/rfc/cookie_spec.html) the entire NAME=VALUE string
of a cookie is a sequence of characters excluding semi-colon, comma and
white space.getCookies
in interface HeaderFields<C extends Cookie,T extends HeaderFields<C,T>>
RequestHeaderFields
instance.public C addCookie(String aCookieName, String aValue)
HeaderFields
ResponseHeaderFields
instance. The server-side cookies are
retrieved from the #HEADER_SET_FIELD_COOKIE
header field.
WITH THE METHOD HeaderFields.getCookies()
and HeaderFields.getCookie(String)
ONLY
THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED. (E.G. COOKIES RESIDING
IN THE HEADER FIELD #HEADER_FIELD_COOKIE). COOKIES SET VIA
HeaderFields.addCookie(String, String)
OR
HeaderFields.withAddCookie(String, String)
CANNOT BE RETRIEVED, AS THE
COOKIES BEING SET SERVER-SIDE ARE PUT IN THE #HEADER_FIELD_COOKIE
.addCookie
in interface HeaderFields<C extends Cookie,T extends HeaderFields<C,T>>
aCookieName
- The name for the cookie to be added.aValue
- The value of the cookie to be added.ResponseHeaderFields
instance!public List<C> getCookie(String aCookieName)
HeaderFields
RequestHeaderFields
instance. The client-side cookies are
retrieved from the #HEADER_FIELD_COOKIE
header field.
WITH THE METHOD HeaderFields.getCookies()
and HeaderFields.getCookie(String)
ONLY
THE COOKIES SENT BY THE CLIENT CAN BE RETRIEVED. (E.G. COOKIES RESIDING
IN THE HEADER FIELD #HEADER_FIELD_COOKIE). COOKIES SET VIA
HeaderFields.addCookie(String, String)
OR
HeaderFields.withAddCookie(String, String)
CANNOT BE RETRIEVED, AS THE
COOKIES BEING SET SERVER-SIDE ARE PUT IN THE #HEADER_FIELD_COOKIE
.getCookie
in interface HeaderFields<C extends Cookie,T extends HeaderFields<C,T>>
aCookieName
- The name of the cookie to be retrieved.protected abstract String getCookieFieldName()
Cookie
elements. The header field
name differs from the context, e.g. when setting a Cookie
server-side or when retrieving a Cookie
client-side.Cookie
elements are stored.protected abstract C createCookie(String aCookieName, String aValue)
Cookie
with the given name and value.Copyright © 2016. All rights reserved.