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,
HttpPartSchema schema,
String name,
Class<T> type)
Same as
get(String, Class) but allows you to override the part parser used. |
<T> T |
get(HttpPartParser parser,
HttpPartSchema schema,
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,
HttpPartSchema schema,
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
|
AcceptCharset |
getAcceptCharset()
Returns the
|
AcceptEncoding |
getAcceptEncoding()
Returns the
|
AcceptLanguage |
getAcceptLanguage()
Returns the
|
Authorization |
getAuthorization()
Returns the
|
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
|
Connection |
getConnection()
Returns the
|
ContentLength |
getContentLength()
Returns the
|
ContentType |
getContentType()
Returns the
|
Date |
getDate()
Returns the
|
Expect |
getExpect()
Returns the
|
From |
getFrom()
Returns the
|
Host |
getHost()
Returns the
|
IfMatch |
getIfMatch()
Returns the
|
IfModifiedSince |
getIfModifiedSince()
Returns the
|
IfNoneMatch |
getIfNoneMatch()
Returns the
|
IfRange |
getIfRange()
Returns the
|
IfUnmodifiedSince |
getIfUnmodifiedSince()
Returns the
|
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
|
Pragma |
getPragma()
Returns the
|
ProxyAuthorization |
getProxyAuthorization()
Returns the
|
Range |
getRange()
Returns the
|
Referer |
getReferer()
Returns the
|
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
|
TimeZone |
getTimeZone()
Returns the
|
Upgrade |
getUpgrade()
Returns the
|
UserAgent |
getUserAgent()
Returns the
|
Via |
getVia()
Returns the
|
Warning |
getWarning()
Returns the
|
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.
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 BadRequest, InternalServerError
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.BadRequest
- Thrown if input could not be parsed.InternalServerError
- Thrown if any other exception occurs.public <T> T get(HttpPartParser parser, HttpPartSchema schema, String name, Class<T> type) throws BadRequest, InternalServerError
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.
schema
- The schema object that defines the format of the input.
HttpPartSchema.DEFAULT
.
OpenApiParser
).name
- The HTTP header name.type
- The class type to convert the header value to.BadRequest
- Thrown if input could not be parsed or fails schema validation.InternalServerError
- Thrown if any other exception occurs.public <T> T get(String name, T def, Class<T> type) throws BadRequest, InternalServerError
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.BadRequest
- Thrown if input could not be parsed.InternalServerError
- Thrown if any other exception occurs.public <T> T get(HttpPartParser parser, HttpPartSchema schema, String name, T def, Class<T> type) throws BadRequest, InternalServerError
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.
schema
- The schema object that defines the format of the input.
HttpPartSchema.DEFAULT
.
OpenApiParser
).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.BadRequest
- Thrown if input could not be parsed or fails schema validation.InternalServerError
- Thrown if any other exception occurs.public <T> T get(String name, Type type, Type... args) throws BadRequest, InternalServerError
HttpPartParser
registered with the resource.
Similar to get(String,Class)
but allows for complex collections of POJOs to be created.
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
BadRequest
- Thrown if input could not be parsed.InternalServerError
- Thrown if any other exception occurs.public <T> T get(HttpPartParser parser, HttpPartSchema schema, String name, Type type, Type... args) throws BadRequest, InternalServerError
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.
schema
- The schema object that defines the format of the input.
HttpPartSchema.DEFAULT
.
OpenApiParser
).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
BadRequest
- Thrown if input could not be parsed or fails schema validation.InternalServerError
- Thrown if any other exception occurs.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()
Content-Types that are acceptable for the response.
Accept: text/plain
public AcceptCharset getAcceptCharset()
Character sets that are acceptable.
Accept-Charset: utf-8
public AcceptEncoding getAcceptEncoding()
List of acceptable encodings.
Accept-Encoding: gzip, deflate
public AcceptLanguage getAcceptLanguage()
List of acceptable human languages for response.
Accept-Language: en-US
public Authorization getAuthorization()
Authentication credentials for HTTP authentication.
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
public CacheControl getCacheControl()
Used to specify directives that must be obeyed by all caching mechanisms along the request-response chain.
Cache-Control: no-cache
public Connection getConnection()
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()
The length of the request body in octets (8-bit bytes).
Content-Length: 348
public ContentType getContentType()
The MIME type of the body of the request (used with POST and PUT requests).
Content-Type: application/x-www-form-urlencoded
public Date getDate()
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
public Expect getExpect()
Indicates that particular server behaviors are required by the client.
Expect: 100-continue
public From getFrom()
The email address of the user making the request.
From: user@example.com
public Host getHost()
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
public IfMatch getIfMatch()
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"
public IfModifiedSince getIfModifiedSince()
Allows a 304 Not Modified to be returned if content is unchanged.
If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT
public IfNoneMatch getIfNoneMatch()
Allows a 304 Not Modified to be returned if content is unchanged, see HTTP ETag.
If-None-Match: "737060cd8c284d8af7ad3082f209582d"
public IfRange getIfRange()
If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity.
If-Range: "737060cd8c284d8af7ad3082f209582d"
public IfUnmodifiedSince getIfUnmodifiedSince()
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
public MaxForwards getMaxForwards()
Limit the number of times the message can be forwarded through proxies or gateways.
Max-Forwards: 10
public Pragma getPragma()
Implementation-specific fields that may have various effects anywhere along the request-response chain.
Pragma: no-cache
public ProxyAuthorization getProxyAuthorization()
Authorization credentials for connecting to a proxy.
Proxy-Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==
public Range getRange()
Request only part of an entity. Bytes are numbered from 0.
Range: bytes=500-999
public Referer getReferer()
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
public TE getTE()
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
public TimeZone getTimeZone()
Example:
public UserAgent getUserAgent()
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
public Upgrade getUpgrade()
Ask the server to upgrade to another protocol.
Upgrade: HTTP/2.0, HTTPS/1.3, IRC/6.9, RTA/x11, websocket
public Via getVia()
Informs the server of proxies through which the request was sent.
Via: 1.0 fred, 1.1 example.com (Apache/1.1)
public Warning getWarning()
A general warning about possible problems with the entity body.
Warning: 199 Miscellaneous warning
public String toString(boolean sorted)
sorted
- Sort the headers by name.Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.