public class RequestHeaders extends TreeMap<String,String[]>
Entries are stored in a case-insensitive map.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
RequestHeaders |
addDefault(Map<String,Object> defaultEntries)
Adds default entries to these headers.
|
RequestHeaders |
addDefault(String name,
Object value)
Adds a default header value on this request.
|
<T> T |
get(HttpPartParser parser,
String name,
Class<T> type)
Same as
get(String, Class) but allows you to override the part parser used. |
<T> T |
get(HttpPartParser parser,
String name,
T def,
Class<T> type)
Same as
get(String, Object, Class) but allows you to override the part parser used. |
<T> T |
get(HttpPartParser parser,
String name,
Type type,
Type... args)
Same as
get(String, Type, Type...) but allows you to override the part parser used. |
<T> T |
get(String name,
Class<T> type)
Returns the specified header value converted to a POJO using the
HttpPartParser registered with the resource. |
<T> T |
get(String name,
T def,
Class<T> type)
Same as
get(String, Class) but returns a default value if not found. |
<T> T |
get(String name,
Type type,
Type... args)
Returns the specified header value converted to a POJO using the
HttpPartParser registered with the resource. |
Accept |
getAccept()
Returns the
Accept header on the request. |
AcceptCharset |
getAcceptCharset()
Returns the
Accept-Charset header on the request. |
AcceptEncoding |
getAcceptEncoding()
Returns the
Accept-Encoding header on the request. |
AcceptLanguage |
getAcceptLanguage()
Returns the
Accept-Language header on the request. |
Authorization |
getAuthorization()
Returns the
Authorization header on the request. |
boolean |
getBoolean(String name)
Same as
getString(String) but converts the value to a boolean. |
boolean |
getBoolean(String name,
boolean def)
Same as
getString(String,String) but converts the value to a boolean. |
CacheControl |
getCacheControl()
Returns the
Cache-Control header on the request. |
Connection |
getConnection()
Returns the
Connection header on the request. |
ContentLength |
getContentLength()
Returns the
Content-Length header on the request. |
ContentType |
getContentType()
Returns the
Content-Type header on the request. |
Date |
getDate()
Returns the
Date header on the request. |
Expect |
getExpect()
Returns the
Expect header on the request. |
From |
getFrom()
Returns the
From header on the request. |
Host |
getHost()
Returns the
Host header on the request. |
IfMatch |
getIfMatch()
Returns the
If-Match header on the request. |
IfModifiedSince |
getIfModifiedSince()
Returns the
If-Modified-Since header on the request. |
IfNoneMatch |
getIfNoneMatch()
Returns the
If-None-Match header on the request. |
IfRange |
getIfRange()
Returns the
If-Range header on the request. |
IfUnmodifiedSince |
getIfUnmodifiedSince()
Returns the
If-Unmodified-Since header on the request. |
int |
getInt(String name)
Same as
getString(String) but converts the value to an integer. |
int |
getInt(String name,
int def)
Same as
getString(String,String) but converts the value to an integer. |
MaxForwards |
getMaxForwards()
Returns the
Max-Forwards header on the request. |
Pragma |
getPragma()
Returns the
Pragma header on the request. |
ProxyAuthorization |
getProxyAuthorization()
Returns the
Proxy-Authorization header on the request. |
Range |
getRange()
Returns the
Range header on the request. |
Referer |
getReferer()
Returns the
Referer header on the request. |
String |
getString(String name)
Returns the specified header value as a string.
|
String |
getString(String name,
String def)
Returns the specified header value as a string.
|
TE |
getTE()
Returns the
TE header on the request. |
TimeZone |
getTimeZone()
Returns the
Time-Zone header value on the request if there is one. |
Upgrade |
getUpgrade()
Returns the
Upgrade header on the request. |
UserAgent |
getUserAgent()
Returns the
User-Agent header on the request. |
Via |
getVia()
Returns the
Via header on the request. |
Warning |
getWarning()
Returns the
Warning header on the request. |
RequestHeaders |
put(String name,
Enumeration<String> values)
Adds a set of header values to this object.
|
void |
put(String name,
Object value)
Sets a request header value.
|
RequestHeaders |
subset(String... headers)
Returns a copy of this object but only with the specified header names copied.
|
RequestHeaders |
subset(String headers)
Same as
subset(String...) but allows you to specify header names as a comma-delimited list. |
String |
toString() |
String |
toString(boolean sorted)
Converts the headers to a readable string.
|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, forEach, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, put, putAll, remove, replace, replace, replaceAll, size, subMap, subMap, tailMap, tailMap, values
equals, hashCode, isEmpty
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove
public RequestHeaders addDefault(Map<String,Object> defaultEntries)
Similar to put(String, Object)
but doesn't override existing values.
defaultEntries
- The default entries.
public RequestHeaders addDefault(String name, Object value)
Similar to put(String, Object)
but doesn't override existing values.
name
- The header name.value
- The header value.
toString()
.
public RequestHeaders put(String name, Enumeration<String> values)
name
- The header name.values
- The header values.public String getString(String name)
allowHeaderParams
init parameter is &HeaderName=x
in the URL query string.
name
- The header name.public String getString(String name, String def)
allowHeaderParams
init parameter is &HeaderName=x
in the URL query string.
name
- The HTTP header name.def
- The default value to return if the header value isn't found.public int getInt(String name)
getString(String)
but converts the value to an integer.name
- The HTTP header name.public int getInt(String name, int def)
getString(String,String)
but converts the value to an integer.name
- The HTTP header name.def
- The default value to return if the header value isn't found.public boolean getBoolean(String name)
getString(String)
but converts the value to a boolean.name
- The HTTP header name.public boolean getBoolean(String name, boolean def)
getString(String,String)
but converts the value to a boolean.name
- The HTTP header name.def
- The default value to return if the header value isn't found.public void put(String name, Object value)
This overwrites any previous value.
name
- The header name.value
- The header value.public <T> T get(String name, Class<T> type) throws ParseException
HttpPartParser
registered with the resource.
allowHeaderParams
init parameter is &HeaderName=x
in the URL query string.
T
- The class type to convert the header value to.name
- The HTTP header name.type
- The class type to convert the header value to.ParseException
public <T> T get(HttpPartParser parser, String name, Class<T> type) throws ParseException
get(String, Class)
but allows you to override the part parser used.T
- The class type to convert the header value to.parser
- The parser to use for parsing the string header.
name
- The HTTP header name.type
- The class type to convert the header value to.ParseException
public <T> T get(String name, T def, Class<T> type) throws ParseException
get(String, Class)
but returns a default value if not found.T
- The class type to convert the header value to.name
- The HTTP header name.def
- The default value if the header was not specified or is type
- The class type to convert the header value to.ParseException
public <T> T get(HttpPartParser parser, String name, T def, Class<T> type) throws ParseException
get(String, Object, Class)
but allows you to override the part parser used.T
- The class type to convert the header value to.parser
- The parser to use for parsing the string header.
name
- The HTTP header name.def
- The default value if the header was not specified or is type
- The class type to convert the header value to.ParseException
public <T> T get(String name, Type type, Type... args) throws ParseException
HttpPartParser
registered with the resource.
Similar to get(String,Class)
but allows for complex collections of POJOs to be created.
Collections
must be followed by zero or one parameter representing the value type.
Maps
must be followed by zero or two parameters representing the key and value types.
allowHeaderParams
init parameter is &HeaderName=x
in the URL query string.
T
- The class type to convert the header value to.name
- The HTTP header name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
- If the header could not be converted to the specified type.public <T> T get(HttpPartParser parser, String name, Type type, Type... args) throws ParseException
get(String, Type, Type...)
but allows you to override the part parser used.T
- The class type to convert the header value to.parser
- The parser to use for parsing the string header.
name
- The HTTP header name.type
- The type of object to create.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
args
- The type arguments of the class if it's a collection or map.
ClassMeta
, Class
, ParameterizedType
, GenericArrayType
ParseException
- If the header could not be converted to the specified type.public RequestHeaders subset(String... headers)
headers
- The headers to include in the copy.public RequestHeaders subset(String headers)
subset(String...)
but allows you to specify header names as a comma-delimited list.headers
- The headers to include in the copy.public Accept getAccept()
Accept
header on the request.
Content-Types that are acceptable for the response.
Accept: text/plain
Accept
header on the request, or public AcceptCharset getAcceptCharset()
Accept-Charset
header on the request.
Character sets that are acceptable.
Accept-Charset: utf-8
Accept-Charset
header on the request, or public AcceptEncoding getAcceptEncoding()
Accept-Encoding
header on the request.
List of acceptable encodings.
Accept-Encoding: gzip, deflate
Accept-Encoding
header on the request, or public AcceptLanguage getAcceptLanguage()
Accept-Language
header on the request.
List of acceptable human languages for response.
Accept-Language: en-US
Accept-Language
header on the request, or public Authorization getAuthorization()
Authorization
header on the request.
Authentication credentials for HTTP authentication.
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Authorization
header on the request, or public CacheControl getCacheControl()
Cache-Control
header on the request.
Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
Cache-Control: no-cache
Cache-Control
header on the request, or public Connection getConnection()
Connection
header on the request.
Control options for the current connection and list of hop-by-hop request fields.
Connection: keep-alive Connection: Upgrade
header on the request, or public ContentLength getContentLength()
Content-Length
header on the request.
The length of the request body in octets (8-bit bytes).
Content-Length: 348
Content-Length
header on the request, or public ContentType getContentType()
Content-Type
header on the request.
The MIME type of the body of the request (used with POST and PUT requests).
Content-Type: application/x-www-form-urlencoded
Content-Type
header on the request, or public Date getDate()
Date
header on the request.
The date and time that the message was originated (in "HTTP-date" format as defined by RFC 7231 Date/Time Formats).
Date: Tue, 15 Nov 1994 08:12:31 GMT
Date
header on the request, or public Expect getExpect()
Expect
header on the request.
Indicates that particular server behaviors are required by the client.
Expect: 100-continue
Expect
header on the request, or public From getFrom()
From
header on the request.
The email address of the user making the request.
From: user@example.com
From
header on the request, or public Host getHost()
Host
header on the request.
The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening. The port number may be omitted if the port is the standard port for the service requested.
Host: en.wikipedia.org:8080 Host: en.wikipedia.org
Host
header on the request, or public IfMatch getIfMatch()
If-Match
header on the request.
Only perform the action if the client supplied entity matches the same entity on the server. This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it.
If-Match: "737060cd8c284d8af7ad3082f209582d"
If-Match
header on the request, or public IfModifiedSince getIfModifiedSince()
If-Modified-Since
header on the request.
Allows a 304 Not Modified to be returned if content is unchanged.
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
If-Modified-Since
header on the request, or public IfNoneMatch getIfNoneMatch()
If-None-Match
header on the request.
Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag.
If-None-Match: "737060cd8c284d8af7ad3082f209582d"
If-None-Match
header on the request, or public IfRange getIfRange()
If-Range
header on the request.
If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity.
If-Range: "737060cd8c284d8af7ad3082f209582d"
If-Range
header on the request, or public IfUnmodifiedSince getIfUnmodifiedSince()
If-Unmodified-Since
header on the request.
Only send the response if the entity has not been modified since a specific time.
If-Unmodified-Since: Sat, 29 Oct 1994 19:43:31 GMT
If-Unmodified-Since
header on the request, or public MaxForwards getMaxForwards()
Max-Forwards
header on the request.
Limit the number of times the message can be forwarded through proxies or gateways.
Max-Forwards: 10
Max-Forwards
header on the request, or public Pragma getPragma()
Pragma
header on the request.
Implementation-specific fields that may have various effects anywhere along the request-response chain.
Pragma: no-cache
Pragma
header on the request, or public ProxyAuthorization getProxyAuthorization()
Proxy-Authorization
header on the request.
Authorization credentials for connecting to a proxy.
Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
Proxy-Authorization
header on the request, or public Range getRange()
Range
header on the request.
Request only part of an entity. Bytes are numbered from 0.
Range: bytes=500-999
Range
header on the request, or public Referer getReferer()
Referer
header on the request.
This is the address of the previous web page from which a link to the currently requested page was followed.
Referer: http://en.wikipedia.org/wiki/Main_Page
Referer
header on the request, or public TE getTE()
TE
header on the request.
The transfer encodings the user agent is willing to accept: the same values as for the response header field Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to notify the server it expects to receive additional fields in the trailer after the last, zero-sized, chunk.
TE: trailers, deflate
TE
header on the request, or public TimeZone getTimeZone()
Time-Zone
header value on the request if there is one.
Example:
Time-Zone
header value on the request, or public UserAgent getUserAgent()
User-Agent
header on the request.
The user agent string of the user agent.
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0
User-Agent
header on the request, or public Upgrade getUpgrade()
Upgrade
header on the request.
Ask the server to upgrade to another protocol.
Upgrade: HTTP/2.0, HTTPS/1.3, IRC/6.9, RTA/x11, websocket
Upgrade
header on the request, or public Via getVia()
Via
header on the request.
Informs the server of proxies through which the request was sent.
Via: 1.0 fred, 1.1 example.com (Apache/1.1)
Via
header on the request, or public Warning getWarning()
Warning
header on the request.
A general warning about possible problems with the entity body.
Warning: 199 Miscellaneous warning
Warning
header on the request, or public String toString(boolean sorted)
sorted
- Sort the headers by name.Copyright © 2018 Apache. All rights reserved.