Class HttpHeaders
- java.lang.Object
-
- com.foxinmy.weixin4j.http.HttpHeaders
-
- All Implemented Interfaces:
MultiValueMap<String,String>
,Serializable
,Map<String,List<String>>
public class HttpHeaders extends Object implements MultiValueMap<String,String>, Serializable
Represents HTTP request and response headers, mapping string header names to list of string values.In addition to the normal methods defined by
Map
, this class offers the following convenience methods:getFirst(String)
returns the first value associated with a given header nameadd(String, String)
adds a header value to the list of values for a header nameset(String, String)
sets the header value to a single string value
- Since:
- 3.0
- Author:
- Arjen Poutsma, Sebastien Deleuze
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCEPT
The HTTPAccept
header field name.static String
ACCEPT_CHARSET
The HTTPAccept-Charset
header field name.static String
ACCEPT_ENCODING
The HTTPAccept-Encoding
header field name.static String
ACCEPT_LANGUAGE
The HTTPAccept-Language
header field name.static String
ACCEPT_RANGES
The HTTPAccept-Ranges
header field name.static String
ACCESS_CONTROL_ALLOW_CREDENTIALS
The CORSAccess-Control-Allow-Credentials
response header field name.static String
ACCESS_CONTROL_ALLOW_HEADERS
The CORSAccess-Control-Allow-Headers
response header field name.static String
ACCESS_CONTROL_ALLOW_METHODS
The CORSAccess-Control-Allow-Methods
response header field name.static String
ACCESS_CONTROL_ALLOW_ORIGIN
The CORSAccess-Control-Allow-Origin
response header field name.static String
ACCESS_CONTROL_EXPOSE_HEADERS
The CORSAccess-Control-Expose-Headers
response header field name.static String
ACCESS_CONTROL_MAX_AGE
The CORSAccess-Control-Max-Age
response header field name.static String
ACCESS_CONTROL_REQUEST_HEADERS
The CORSAccess-Control-Request-Headers
request header field name.static String
ACCESS_CONTROL_REQUEST_METHOD
The CORSAccess-Control-Request-Method
request header field name.static String
AGE
The HTTPAge
header field name.static String
ALLOW
The HTTPAllow
header field name.static String
AUTHORIZATION
The HTTPAuthorization
header field name.static String
CACHE_CONTROL
The HTTPCache-Control
header field name.static String
CONNECTION
The HTTPConnection
header field name.static String
CONTENT_DISPOSITION
The HTTPContent-Disposition
header field namestatic String
CONTENT_ENCODING
The HTTPContent-Encoding
header field name.static String
CONTENT_LANGUAGE
The HTTPContent-Language
header field name.static String
CONTENT_LENGTH
The HTTPContent-Length
header field name.static String
CONTENT_LOCATION
The HTTPContent-Location
header field name.static String
CONTENT_RANGE
The HTTPContent-Range
header field name.static String
CONTENT_TYPE
The HTTPContent-Type
header field name.static String
COOKIE
The HTTPCookie
header field name.static String
DATE
The HTTPDate
header field name.static String
ETAG
The HTTPETag
header field name.static String
EXPECT
The HTTPExpect
header field name.static String
EXPIRES
The HTTPExpires
header field name.static String
FROM
The HTTPFrom
header field name.static String
HOST
The HTTPHost
header field name.static String
IF_MATCH
The HTTPIf-Match
header field name.static String
IF_MODIFIED_SINCE
The HTTPIf-Modified-Since
header field name.static String
IF_NONE_MATCH
The HTTPIf-None-Match
header field name.static String
IF_RANGE
The HTTPIf-Range
header field name.static String
IF_UNMODIFIED_SINCE
The HTTPIf-Unmodified-Since
header field name.static String
LAST_MODIFIED
The HTTPLast-Modified
header field name.static String
LINK
The HTTPLink
header field name.static String
LOCATION
The HTTPLocation
header field name.static String
MAX_FORWARDS
The HTTPMax-Forwards
header field name.static String
ORIGIN
The HTTPOrigin
header field name.static String
PRAGMA
The HTTPPragma
header field name.static String
PROXY_AUTHENTICATE
The HTTPProxy-Authenticate
header field name.static String
PROXY_AUTHORIZATION
The HTTPProxy-Authorization
header field name.static String
RANGE
The HTTPRange
header field name.static String
REFERER
The HTTPReferer
header field name.static String
RETRY_AFTER
The HTTPRetry-After
header field name.static String
SERVER
The HTTPServer
header field name.static String
SET_COOKIE
The HTTPSet-Cookie
header field name.static String
SET_COOKIE2
The HTTPSet-Cookie2
header field name.static String
TE
The HTTPTE
header field name.static String
TRAILER
The HTTPTrailer
header field name.static String
TRANSFER_ENCODING
The HTTPTransfer-Encoding
header field name.static String
UPGRADE
The HTTPUpgrade
header field name.static String
USER_AGENT
The HTTPUser-Agent
header field name.static String
VARY
The HTTPVary
header field name.static String
VIA
The HTTPVia
header field name.static String
WARNING
The HTTPWarning
header field name.static String
WWW_AUTHENTICATE
The HTTPWWW-Authenticate
header field name.
-
Constructor Summary
Constructors Constructor Description HttpHeaders()
Constructs a new, empty instance of theHttpHeaders
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(String headerName, String headerValue)
Add the given, single header value under the given name.void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<String,List<String>>>
entrySet()
boolean
equals(Object other)
List<String>
get(Object key)
String
getAccept()
Return the list of acceptable media types, as specified by theAccept
header.List<Charset>
getAcceptCharset()
Return the list of acceptable charsets, as specified by theAccept-Charset
header.boolean
getAccessControlAllowCredentials()
Returns the value of theAccess-Control-Allow-Credentials
response header.List<String>
getAccessControlAllowHeaders()
Returns the value of theAccess-Control-Allow-Headers
response header.List<HttpMethod>
getAccessControlAllowMethods()
Returns the value of theAccess-Control-Allow-Methods
response header.String
getAccessControlAllowOrigin()
Returns the value of theAccess-Control-Allow-Origin
response header.List<String>
getAccessControlExposeHeaders()
Returns the value of theAccess-Control-Expose-Headers
response header.long
getAccessControlMaxAge()
Returns the value of theAccess-Control-Max-Age
response header.List<String>
getAccessControlRequestHeaders()
Returns the value of theAccess-Control-Request-Headers
request header.HttpMethod
getAccessControlRequestMethod()
Returns the value of theAccess-Control-Request-Method
request header.Set<HttpMethod>
getAllow()
Return the set of allowedHTTP methods
, as specified by theAllow
header.String
getCacheControl()
Returns the value of theCache-Control
header.List<String>
getConnection()
Returns the value of theConnection
header.long
getContentLength()
Return the length of the body in bytes, as specified by theContent-Length
header.String
getContentType()
Return the media type of the body, as specified by theContent-Type
header.long
getDate()
Return the date and time at which the message was created, as specified by theDate
header.String
getETag()
Return the entity tag of the body, as specified by theETag
header.long
getExpires()
Return the date and time at which the message is no longer valid, as specified by theExpires
header.String
getFirst(String headerName)
Return the first header value for the given header name, if any.long
getFirstDate(String headerName)
Parse the first header value for the given header name as a date, return -1 if there is no value, or raiseIllegalArgumentException
if the value cannot be parsed as a date.protected List<String>
getFirstValueAsList(String header)
long
getIfModifiedSince()
Return the value of theIf-Modified-Since
header.List<String>
getIfNoneMatch()
Return the value of theIf-None-Match
header.long
getLastModified()
Return the time the resource was last changed, as specified by theLast-Modified
header.URI
getLocation()
Return the (new) location of a resource as specified by theLocation
header.String
getOrigin()
Return the value of theOrigin
header.String
getPragma()
Return the value of thePragma
header.String
getRange()
Returns the value of theRange
header.String
getUpgrade()
Returns the value of theUpgrade
header.int
hashCode()
boolean
isEmpty()
Set<String>
keySet()
List<String>
put(String key, List<String> value)
void
putAll(Map<? extends String,? extends List<String>> map)
static HttpHeaders
readOnlyHttpHeaders(HttpHeaders headers)
Return aHttpHeaders
object that can only be read, not written to.List<String>
remove(Object key)
void
set(String headerName, String headerValue)
Set the given, single header value under the given name.void
setAccept(List<ContentType> acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.void
setAcceptCharset(List<Charset> acceptableCharsets)
Set the list of acceptable charsets, as specified by theAccept-Charset
header.void
setAccessControlAllowCredentials(boolean allowCredentials)
Set the (new) value of theAccess-Control-Allow-Credentials
response header.void
setAccessControlAllowHeaders(List<String> allowedHeaders)
Set the (new) value of theAccess-Control-Allow-Headers
response header.void
setAccessControlAllowMethods(List<HttpMethod> allowedMethods)
Set the (new) value of theAccess-Control-Allow-Methods
response header.void
setAccessControlAllowOrigin(String allowedOrigin)
Set the (new) value of theAccess-Control-Allow-Origin
response header.void
setAccessControlExposeHeaders(List<String> exposedHeaders)
Set the (new) value of theAccess-Control-Expose-Headers
response header.void
setAccessControlMaxAge(long maxAge)
Set the (new) value of theAccess-Control-Max-Age
response header.void
setAccessControlRequestHeaders(List<String> requestHeaders)
Set the (new) value of theAccess-Control-Request-Headers
request header.void
setAccessControlRequestMethod(HttpMethod requestedMethod)
Set the (new) value of theAccess-Control-Request-Method
request header.void
setAll(Map<String,String> values)
Set the given values under.void
setAllow(Set<HttpMethod> allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.void
setCacheControl(String cacheControl)
Set the (new) value of theCache-Control
header.void
setConnection(String connection)
Set the (new) value of theConnection
header.void
setConnection(List<String> connection)
Set the (new) value of theConnection
header.void
setContentDispositionFormData(String name, String filename)
Set the (new) value of theContent-Disposition
header forform-data
.void
setContentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.void
setContentType(ContentType contentType)
Set the media type of the body, as specified by theContent-Type
header.void
setDate(long date)
Set the date and time at which the message was created, as specified by theDate
header.void
setDate(String headerName, long date)
Set the given date under the given header name after formatting it as a string using the pattern"EEE, dd MMM yyyy HH:mm:ss zzz"
.void
setETag(String eTag)
Set the (new) entity tag of the body, as specified by theETag
header.void
setExpires(long expires)
Set the date and time at which the message is no longer valid, as specified by theExpires
header.void
setIfModifiedSince(long ifModifiedSince)
Set the (new) value of theIf-Modified-Since
header.void
setIfNoneMatch(String ifNoneMatch)
Set the (new) value of theIf-None-Match
header.void
setIfNoneMatch(List<String> ifNoneMatchList)
Set the (new) values of theIf-None-Match
header.void
setLastModified(long lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.void
setLocation(URI location)
Set the (new) location of a resource, as specified by theLocation
header.void
setOrigin(String origin)
Set the (new) value of theOrigin
header.void
setPragma(String pragma)
Set the (new) value of thePragma
header.void
setRange(String range)
Sets the (new) value of theRange
header.void
setUpgrade(String upgrade)
Set the (new) value of theUpgrade
header.int
size()
protected String
toCommaDelimitedString(List<String> list)
Map<String,String>
toSingleValueMap()
Returns the first values contained in thisMultiValueMap
.String
toString()
Collection<List<String>>
values()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
ACCEPT
public static final String ACCEPT
The HTTPAccept
header field name.- See Also:
- Section 5.3.2 of RFC 7231, Constant Field Values
-
ACCEPT_CHARSET
public static final String ACCEPT_CHARSET
The HTTPAccept-Charset
header field name.- See Also:
- Section 5.3.3 of RFC 7231, Constant Field Values
-
ACCEPT_ENCODING
public static final String ACCEPT_ENCODING
The HTTPAccept-Encoding
header field name.- See Also:
- Section 5.3.4 of RFC 7231, Constant Field Values
-
ACCEPT_LANGUAGE
public static final String ACCEPT_LANGUAGE
The HTTPAccept-Language
header field name.- See Also:
- Section 5.3.5 of RFC 7231, Constant Field Values
-
ACCEPT_RANGES
public static final String ACCEPT_RANGES
The HTTPAccept-Ranges
header field name.- See Also:
- Section 5.3.5 of RFC 7233, Constant Field Values
-
ACCESS_CONTROL_ALLOW_CREDENTIALS
public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS
The CORSAccess-Control-Allow-Credentials
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_ALLOW_HEADERS
public static final String ACCESS_CONTROL_ALLOW_HEADERS
The CORSAccess-Control-Allow-Headers
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_ALLOW_METHODS
public static final String ACCESS_CONTROL_ALLOW_METHODS
The CORSAccess-Control-Allow-Methods
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_ALLOW_ORIGIN
public static final String ACCESS_CONTROL_ALLOW_ORIGIN
The CORSAccess-Control-Allow-Origin
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_EXPOSE_HEADERS
public static final String ACCESS_CONTROL_EXPOSE_HEADERS
The CORSAccess-Control-Expose-Headers
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_MAX_AGE
public static final String ACCESS_CONTROL_MAX_AGE
The CORSAccess-Control-Max-Age
response header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_REQUEST_HEADERS
public static final String ACCESS_CONTROL_REQUEST_HEADERS
The CORSAccess-Control-Request-Headers
request header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
ACCESS_CONTROL_REQUEST_METHOD
public static final String ACCESS_CONTROL_REQUEST_METHOD
The CORSAccess-Control-Request-Method
request header field name.- See Also:
- CORS W3C recommandation, Constant Field Values
-
AGE
public static final String AGE
The HTTPAge
header field name.- See Also:
- Section 5.1 of RFC 7234, Constant Field Values
-
ALLOW
public static final String ALLOW
The HTTPAllow
header field name.- See Also:
- Section 7.4.1 of RFC 7231, Constant Field Values
-
AUTHORIZATION
public static final String AUTHORIZATION
The HTTPAuthorization
header field name.- See Also:
- Section 4.2 of RFC 7235, Constant Field Values
-
CACHE_CONTROL
public static final String CACHE_CONTROL
The HTTPCache-Control
header field name.- See Also:
- Section 5.2 of RFC 7234, Constant Field Values
-
CONNECTION
public static final String CONNECTION
The HTTPConnection
header field name.- See Also:
- Section 6.1 of RFC 7230, Constant Field Values
-
CONTENT_ENCODING
public static final String CONTENT_ENCODING
The HTTPContent-Encoding
header field name.- See Also:
- Section 3.1.2.2 of RFC 7231, Constant Field Values
-
CONTENT_DISPOSITION
public static final String CONTENT_DISPOSITION
The HTTPContent-Disposition
header field name- See Also:
- RFC 6266, Constant Field Values
-
CONTENT_LANGUAGE
public static final String CONTENT_LANGUAGE
The HTTPContent-Language
header field name.- See Also:
- Section 3.1.3.2 of RFC 7231, Constant Field Values
-
CONTENT_LENGTH
public static final String CONTENT_LENGTH
The HTTPContent-Length
header field name.- See Also:
- Section 3.3.2 of RFC 7230, Constant Field Values
-
CONTENT_LOCATION
public static final String CONTENT_LOCATION
The HTTPContent-Location
header field name.- See Also:
- Section 3.1.4.2 of RFC 7231, Constant Field Values
-
CONTENT_RANGE
public static final String CONTENT_RANGE
The HTTPContent-Range
header field name.- See Also:
- Section 4.2 of RFC 7233, Constant Field Values
-
CONTENT_TYPE
public static final String CONTENT_TYPE
The HTTPContent-Type
header field name.- See Also:
- Section 3.1.1.5 of RFC 7231, Constant Field Values
-
COOKIE
public static final String COOKIE
The HTTPCookie
header field name.- See Also:
- Section 4.3.4 of RFC 2109, Constant Field Values
-
DATE
public static final String DATE
The HTTPDate
header field name.- See Also:
- Section 7.1.1.2 of RFC 7231, Constant Field Values
-
ETAG
public static final String ETAG
The HTTPETag
header field name.- See Also:
- Section 2.3 of RFC 7232, Constant Field Values
-
EXPECT
public static final String EXPECT
The HTTPExpect
header field name.- See Also:
- Section 5.1.1 of RFC 7231, Constant Field Values
-
EXPIRES
public static final String EXPIRES
The HTTPExpires
header field name.- See Also:
- Section 5.3 of RFC 7234, Constant Field Values
-
FROM
public static final String FROM
The HTTPFrom
header field name.- See Also:
- Section 5.5.1 of RFC 7231, Constant Field Values
-
HOST
public static final String HOST
The HTTPHost
header field name.- See Also:
- Section 5.4 of RFC 7230, Constant Field Values
-
IF_MATCH
public static final String IF_MATCH
The HTTPIf-Match
header field name.- See Also:
- Section 3.1 of RFC 7232, Constant Field Values
-
IF_MODIFIED_SINCE
public static final String IF_MODIFIED_SINCE
The HTTPIf-Modified-Since
header field name.- See Also:
- Section 3.3 of RFC 7232, Constant Field Values
-
IF_NONE_MATCH
public static final String IF_NONE_MATCH
The HTTPIf-None-Match
header field name.- See Also:
- Section 3.2 of RFC 7232, Constant Field Values
-
IF_RANGE
public static final String IF_RANGE
The HTTPIf-Range
header field name.- See Also:
- Section 3.2 of RFC 7233, Constant Field Values
-
IF_UNMODIFIED_SINCE
public static final String IF_UNMODIFIED_SINCE
The HTTPIf-Unmodified-Since
header field name.- See Also:
- Section 3.4 of RFC 7232, Constant Field Values
-
LAST_MODIFIED
public static final String LAST_MODIFIED
The HTTPLast-Modified
header field name.- See Also:
- Section 2.2 of RFC 7232, Constant Field Values
-
LINK
public static final String LINK
The HTTPLink
header field name.- See Also:
- RFC 5988, Constant Field Values
-
LOCATION
public static final String LOCATION
The HTTPLocation
header field name.- See Also:
- Section 7.1.2 of RFC 7231, Constant Field Values
-
MAX_FORWARDS
public static final String MAX_FORWARDS
The HTTPMax-Forwards
header field name.- See Also:
- Section 5.1.2 of RFC 7231, Constant Field Values
-
ORIGIN
public static final String ORIGIN
The HTTPOrigin
header field name.- See Also:
- RFC 6454, Constant Field Values
-
PRAGMA
public static final String PRAGMA
The HTTPPragma
header field name.- See Also:
- Section 5.4 of RFC 7234, Constant Field Values
-
PROXY_AUTHENTICATE
public static final String PROXY_AUTHENTICATE
The HTTPProxy-Authenticate
header field name.- See Also:
- Section 4.3 of RFC 7235, Constant Field Values
-
PROXY_AUTHORIZATION
public static final String PROXY_AUTHORIZATION
The HTTPProxy-Authorization
header field name.- See Also:
- Section 4.4 of RFC 7235, Constant Field Values
-
RANGE
public static final String RANGE
The HTTPRange
header field name.- See Also:
- Section 3.1 of RFC 7233, Constant Field Values
-
REFERER
public static final String REFERER
The HTTPReferer
header field name.- See Also:
- Section 5.5.2 of RFC 7231, Constant Field Values
-
RETRY_AFTER
public static final String RETRY_AFTER
The HTTPRetry-After
header field name.- See Also:
- Section 7.1.3 of RFC 7231, Constant Field Values
-
SERVER
public static final String SERVER
The HTTPServer
header field name.- See Also:
- Section 7.4.2 of RFC 7231, Constant Field Values
-
SET_COOKIE
public static final String SET_COOKIE
The HTTPSet-Cookie
header field name.- See Also:
- Section 4.2.2 of RFC 2109, Constant Field Values
-
SET_COOKIE2
public static final String SET_COOKIE2
The HTTPSet-Cookie2
header field name.- See Also:
- RFC 2965, Constant Field Values
-
TE
public static final String TE
The HTTPTE
header field name.- See Also:
- Section 4.3 of RFC 7230, Constant Field Values
-
TRAILER
public static final String TRAILER
The HTTPTrailer
header field name.- See Also:
- Section 4.4 of RFC 7230, Constant Field Values
-
TRANSFER_ENCODING
public static final String TRANSFER_ENCODING
The HTTPTransfer-Encoding
header field name.- See Also:
- Section 3.3.1 of RFC 7230, Constant Field Values
-
UPGRADE
public static final String UPGRADE
The HTTPUpgrade
header field name.- See Also:
- Section 6.7 of RFC 7230, Constant Field Values
-
USER_AGENT
public static final String USER_AGENT
The HTTPUser-Agent
header field name.- See Also:
- Section 5.5.3 of RFC 7231, Constant Field Values
-
VARY
public static final String VARY
The HTTPVary
header field name.- See Also:
- Section 7.1.4 of RFC 7231, Constant Field Values
-
VIA
public static final String VIA
The HTTPVia
header field name.- See Also:
- Section 5.7.1 of RFC 7230, Constant Field Values
-
WARNING
public static final String WARNING
The HTTPWarning
header field name.- See Also:
- Section 5.5 of RFC 7234, Constant Field Values
-
WWW_AUTHENTICATE
public static final String WWW_AUTHENTICATE
The HTTPWWW-Authenticate
header field name.- See Also:
- Section 4.1 of RFC 7235, Constant Field Values
-
-
Method Detail
-
setAccept
public void setAccept(List<ContentType> acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.
-
getAccept
public String getAccept()
Return the list of acceptable media types, as specified by theAccept
header.Returns an empty list when the acceptable media types are unspecified.
-
setAccessControlAllowCredentials
public void setAccessControlAllowCredentials(boolean allowCredentials)
Set the (new) value of theAccess-Control-Allow-Credentials
response header.
-
getAccessControlAllowCredentials
public boolean getAccessControlAllowCredentials()
Returns the value of theAccess-Control-Allow-Credentials
response header.
-
setAccessControlAllowHeaders
public void setAccessControlAllowHeaders(List<String> allowedHeaders)
Set the (new) value of theAccess-Control-Allow-Headers
response header.
-
getAccessControlAllowHeaders
public List<String> getAccessControlAllowHeaders()
Returns the value of theAccess-Control-Allow-Headers
response header.
-
setAccessControlAllowMethods
public void setAccessControlAllowMethods(List<HttpMethod> allowedMethods)
Set the (new) value of theAccess-Control-Allow-Methods
response header.
-
getAccessControlAllowMethods
public List<HttpMethod> getAccessControlAllowMethods()
Returns the value of theAccess-Control-Allow-Methods
response header.
-
setAccessControlAllowOrigin
public void setAccessControlAllowOrigin(String allowedOrigin)
Set the (new) value of theAccess-Control-Allow-Origin
response header.
-
getAccessControlAllowOrigin
public String getAccessControlAllowOrigin()
Returns the value of theAccess-Control-Allow-Origin
response header.
-
setAccessControlExposeHeaders
public void setAccessControlExposeHeaders(List<String> exposedHeaders)
Set the (new) value of theAccess-Control-Expose-Headers
response header.
-
getAccessControlExposeHeaders
public List<String> getAccessControlExposeHeaders()
Returns the value of theAccess-Control-Expose-Headers
response header.
-
setAccessControlMaxAge
public void setAccessControlMaxAge(long maxAge)
Set the (new) value of theAccess-Control-Max-Age
response header.
-
getAccessControlMaxAge
public long getAccessControlMaxAge()
Returns the value of theAccess-Control-Max-Age
response header.Returns -1 when the max age is unknown.
-
setAccessControlRequestHeaders
public void setAccessControlRequestHeaders(List<String> requestHeaders)
Set the (new) value of theAccess-Control-Request-Headers
request header.
-
getAccessControlRequestHeaders
public List<String> getAccessControlRequestHeaders()
Returns the value of theAccess-Control-Request-Headers
request header.
-
setAccessControlRequestMethod
public void setAccessControlRequestMethod(HttpMethod requestedMethod)
Set the (new) value of theAccess-Control-Request-Method
request header.
-
getAccessControlRequestMethod
public HttpMethod getAccessControlRequestMethod()
Returns the value of theAccess-Control-Request-Method
request header.
-
setAcceptCharset
public void setAcceptCharset(List<Charset> acceptableCharsets)
Set the list of acceptable charsets, as specified by theAccept-Charset
header.
-
getAcceptCharset
public List<Charset> getAcceptCharset()
Return the list of acceptable charsets, as specified by theAccept-Charset
header.
-
setAllow
public void setAllow(Set<HttpMethod> allowedMethods)
Set the set of allowedHTTP methods
, as specified by theAllow
header.
-
getAllow
public Set<HttpMethod> getAllow()
Return the set of allowedHTTP methods
, as specified by theAllow
header.Returns an empty set when the allowed methods are unspecified.
-
setCacheControl
public void setCacheControl(String cacheControl)
Set the (new) value of theCache-Control
header.
-
getCacheControl
public String getCacheControl()
Returns the value of theCache-Control
header.
-
setConnection
public void setConnection(String connection)
Set the (new) value of theConnection
header.
-
setConnection
public void setConnection(List<String> connection)
Set the (new) value of theConnection
header.
-
setContentDispositionFormData
public void setContentDispositionFormData(String name, String filename)
Set the (new) value of theContent-Disposition
header forform-data
.- Parameters:
name
- the control namefilename
- the filename (may benull
)
-
setContentLength
public void setContentLength(long contentLength)
Set the length of the body in bytes, as specified by theContent-Length
header.
-
getContentLength
public long getContentLength()
Return the length of the body in bytes, as specified by theContent-Length
header.Returns -1 when the content-length is unknown.
-
setContentType
public void setContentType(ContentType contentType)
Set the media type of the body, as specified by theContent-Type
header.
-
getContentType
public String getContentType()
Return the media type of the body, as specified by theContent-Type
header.Returns
null
when the content-type is unknown.
-
setDate
public void setDate(long date)
Set the date and time at which the message was created, as specified by theDate
header.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getDate
public long getDate()
Return the date and time at which the message was created, as specified by theDate
header.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
- Throws:
IllegalArgumentException
- if the value can't be converted to a date
-
setETag
public void setETag(String eTag)
Set the (new) entity tag of the body, as specified by theETag
header.
-
getETag
public String getETag()
Return the entity tag of the body, as specified by theETag
header.
-
setExpires
public void setExpires(long expires)
Set the date and time at which the message is no longer valid, as specified by theExpires
header.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getExpires
public long getExpires()
Return the date and time at which the message is no longer valid, as specified by theExpires
header.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setIfModifiedSince
public void setIfModifiedSince(long ifModifiedSince)
Set the (new) value of theIf-Modified-Since
header.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getIfModifiedSince
public long getIfModifiedSince()
Return the value of theIf-Modified-Since
header.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setIfNoneMatch
public void setIfNoneMatch(String ifNoneMatch)
Set the (new) value of theIf-None-Match
header.
-
setIfNoneMatch
public void setIfNoneMatch(List<String> ifNoneMatchList)
Set the (new) values of theIf-None-Match
header.
-
setLastModified
public void setLastModified(long lastModified)
Set the time the resource was last changed, as specified by theLast-Modified
header.The date should be specified as the number of milliseconds since January 1, 1970 GMT.
-
getLastModified
public long getLastModified()
Return the time the resource was last changed, as specified by theLast-Modified
header.The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
-
setLocation
public void setLocation(URI location)
Set the (new) location of a resource, as specified by theLocation
header.
-
getLocation
public URI getLocation()
Return the (new) location of a resource as specified by theLocation
header.Returns
null
when the location is unknown.
-
setOrigin
public void setOrigin(String origin)
Set the (new) value of theOrigin
header.
-
getOrigin
public String getOrigin()
Return the value of theOrigin
header.
-
setPragma
public void setPragma(String pragma)
Set the (new) value of thePragma
header.
-
getPragma
public String getPragma()
Return the value of thePragma
header.
-
setRange
public void setRange(String range)
Sets the (new) value of theRange
header.
-
getRange
public String getRange()
Returns the value of theRange
header.Returns an empty list when the range is unknown.
-
setUpgrade
public void setUpgrade(String upgrade)
Set the (new) value of theUpgrade
header.
-
getUpgrade
public String getUpgrade()
Returns the value of theUpgrade
header.
-
getFirstDate
public long getFirstDate(String headerName)
Parse the first header value for the given header name as a date, return -1 if there is no value, or raiseIllegalArgumentException
if the value cannot be parsed as a date.
-
setDate
public void setDate(String headerName, long date)
Set the given date under the given header name after formatting it as a string using the pattern"EEE, dd MMM yyyy HH:mm:ss zzz"
. The equivalent ofset(String, String)
but for date headers.
-
getFirst
public String getFirst(String headerName)
Return the first header value for the given header name, if any.- Specified by:
getFirst
in interfaceMultiValueMap<String,String>
- Parameters:
headerName
- the header name- Returns:
- the first header value, or
null
if none
-
add
public void add(String headerName, String headerValue)
Add the given, single header value under the given name.- Specified by:
add
in interfaceMultiValueMap<String,String>
- Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
put(String, List)
,set(String, String)
-
set
public void set(String headerName, String headerValue)
Set the given, single header value under the given name.- Specified by:
set
in interfaceMultiValueMap<String,String>
- Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
put(String, List)
,add(String, String)
-
setAll
public void setAll(Map<String,String> values)
Description copied from interface:MultiValueMap
Set the given values under.- Specified by:
setAll
in interfaceMultiValueMap<String,String>
- Parameters:
values
- the values.
-
toSingleValueMap
public Map<String,String> toSingleValueMap()
Description copied from interface:MultiValueMap
Returns the first values contained in thisMultiValueMap
.- Specified by:
toSingleValueMap
in interfaceMultiValueMap<String,String>
- Returns:
- a single value representation of this map
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<String,List<String>>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<String,List<String>>
-
values
public Collection<List<String>> values()
-
equals
public boolean equals(Object other)
-
hashCode
public int hashCode()
-
readOnlyHttpHeaders
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers)
Return aHttpHeaders
object that can only be read, not written to.
-
-