|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.http.HttpHeaders
public class HttpHeaders
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 valueInspired by Headers
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry<K,V> |
Constructor Summary | |
---|---|
HttpHeaders()
Constructs a new, empty instance of the HttpHeaders object. |
Method Summary | |
---|---|
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)
|
List<MediaType> |
getAccept()
Return the list of acceptable media types, as specified by the Accept header. |
List<Charset> |
getAcceptCharset()
Return the list of acceptable charsets, as specified by the Accept-Charset
header. |
Set<HttpMethod> |
getAllow()
Return the set of allowed HTTP methods , as specified by the Allow header. |
String |
getCacheControl()
Returns the value of the Cache-Control header. |
long |
getContentLength()
Return the length of the body in bytes, as specified by the Content-Length header. |
MediaType |
getContentType()
Return the media type of the body, as specified by the Content-Type header. |
long |
getDate()
Returns the date and time at which the message was created, as specified by the Date header. |
String |
getETag()
Returns the entity tag of the body, as specified by the ETag header. |
long |
getExpires()
Returns the date and time at which the message is no longer valid, as specified by the Expires header. |
String |
getFirst(String headerName)
Return the first header value for the given header name, if any. |
List<String> |
getIfNoneMatch()
Returns the value of the If-None-Match header. |
long |
getIfNotModifiedSince()
Returns the value of the IfModifiedSince header. |
long |
getLastModified()
Returns the time the resource was last changed, as specified by the Last-Modified header. |
URI |
getLocation()
Return the (new) location of a resource, as specified by the Location header. |
String |
getPragma()
Returns the value of the Pragma header. |
int |
hashCode()
|
boolean |
isEmpty()
|
Set<String> |
keySet()
|
List<String> |
put(String key,
List<String> value)
|
void |
putAll(Map<? extends String,? extends List<String>> m)
|
static HttpHeaders |
readOnlyHttpHeaders(HttpHeaders headers)
Returns HttpHeaders 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<MediaType> acceptableMediaTypes)
Set the list of acceptable media types, as specified by the Accept header. |
void |
setAcceptCharset(List<Charset> acceptableCharsets)
Set the list of acceptable charsets, as specified by the Accept-Charset header. |
void |
setAll(Map<String,String> values)
Set the given values under. |
void |
setAllow(Set<HttpMethod> allowedMethods)
Set the set of allowed HTTP methods , as specified by the Allow header. |
void |
setCacheControl(String cacheControl)
Sets the (new) value of the Cache-Control header. |
void |
setContentDispositionFormData(String name,
String filename)
Sets the (new) value of the Content-Disposition header for form-data . |
void |
setContentLength(long contentLength)
Set the length of the body in bytes, as specified by the Content-Length header. |
void |
setContentType(MediaType mediaType)
Set the media type of the body, as specified by the Content-Type header. |
void |
setDate(long date)
Sets the date and time at which the message was created, as specified by the Date header. |
void |
setETag(String eTag)
Sets the (new) entity tag of the body, as specified by the ETag header. |
void |
setExpires(long expires)
Sets the date and time at which the message is no longer valid, as specified by the Expires header. |
void |
setIfModifiedSince(long ifModifiedSince)
Sets the (new) value of the If-Modified-Since header. |
void |
setIfNoneMatch(List<String> ifNoneMatchList)
Sets the (new) values of the If-None-Match header. |
void |
setIfNoneMatch(String ifNoneMatch)
Sets the (new) value of the If-None-Match header. |
void |
setLastModified(long lastModified)
Sets the time the resource was last changed, as specified by the Last-Modified header. |
void |
setLocation(URI location)
Set the (new) location of a resource, as specified by the Location header. |
void |
setPragma(String pragma)
Sets the (new) value of the Pragma header. |
int |
size()
|
Map<String,String> |
toSingleValueMap()
Returns the first values contained in this MultiValueMap . |
String |
toString()
|
Collection<List<String>> |
values()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public HttpHeaders()
HttpHeaders
object.
Method Detail |
---|
public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers)
HttpHeaders
object that can only be read, not written to.
public void setAccept(List<MediaType> acceptableMediaTypes)
Accept
header.
acceptableMediaTypes
- the acceptable media typespublic List<MediaType> getAccept()
Accept
header.
Returns an empty list when the acceptable media types are unspecified.
public void setAcceptCharset(List<Charset> acceptableCharsets)
Accept-Charset
header.
acceptableCharsets
- the acceptable charsetspublic List<Charset> getAcceptCharset()
Accept-Charset
header.
public void setAllow(Set<HttpMethod> allowedMethods)
HTTP methods
, as specified by the Allow
header.
allowedMethods
- the allowed methodspublic Set<HttpMethod> getAllow()
HTTP methods
, as specified by the Allow
header.
Returns an empty set when the allowed methods are unspecified.
public void setCacheControl(String cacheControl)
Cache-Control
header.
cacheControl
- the value of the headerpublic String getCacheControl()
Cache-Control
header.
public void setContentDispositionFormData(String name, String filename)
Content-Disposition
header for form-data
.
name
- the control namefilename
- the filename, may be null
public void setContentLength(long contentLength)
Content-Length
header.
contentLength
- the content lengthpublic long getContentLength()
Content-Length
header.
Returns -1 when the content-length is unknown.
public void setContentType(MediaType mediaType)
Content-Type
header.
mediaType
- the media typepublic MediaType getContentType()
Content-Type
header.
Returns null
when the content-type is unknown.
public void setDate(long date)
Date
header.
The date should be specified as the number of milliseconds since January 1, 1970 GMT.
date
- the datepublic long getDate()
Date
header.
The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
IllegalArgumentException
- if the value can't be converted to a datepublic void setETag(String eTag)
ETag
header.
eTag
- the new entity tagpublic String getETag()
ETag
header.
public void setExpires(long expires)
Expires
header.
The date should be specified as the number of milliseconds since January 1, 1970 GMT.
expires
- the new expires header valuepublic long getExpires()
Expires
header.
The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
public void setIfModifiedSince(long ifModifiedSince)
If-Modified-Since
header.
The date should be specified as the number of milliseconds since January 1, 1970 GMT.
ifModifiedSince
- the new value of the headerpublic long getIfNotModifiedSince()
IfModifiedSince
header.
The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
public void setIfNoneMatch(String ifNoneMatch)
If-None-Match
header.
ifNoneMatch
- the new value of the headerpublic void setIfNoneMatch(List<String> ifNoneMatchList)
If-None-Match
header.
ifNoneMatchList
- the new value of the headerpublic List<String> getIfNoneMatch()
If-None-Match
header.
public void setLastModified(long lastModified)
Last-Modified
header.
The date should be specified as the number of milliseconds since January 1, 1970 GMT.
lastModified
- the last modified datepublic long getLastModified()
Last-Modified
header.
The date is returned as the number of milliseconds since January 1, 1970 GMT. Returns -1 when the date is unknown.
public void setLocation(URI location)
Location
header.
location
- the locationpublic URI getLocation()
Location
header.
Returns null
when the location is unknown.
public void setPragma(String pragma)
Pragma
header.
pragma
- the value of the headerpublic String getPragma()
Pragma
header.
public String getFirst(String headerName)
getFirst
in interface MultiValueMap<String,String>
headerName
- the header name
null
public void add(String headerName, String headerValue)
add
in interface MultiValueMap<String,String>
headerName
- the header nameheaderValue
- the header value
UnsupportedOperationException
- if adding headers is not supportedput(String, List)
,
set(String, String)
public void set(String headerName, String headerValue)
set
in interface MultiValueMap<String,String>
headerName
- the header nameheaderValue
- the header value
UnsupportedOperationException
- if adding headers is not supportedput(String, List)
,
add(String, String)
public void setAll(Map<String,String> values)
MultiValueMap
setAll
in interface MultiValueMap<String,String>
values
- the values.public Map<String,String> toSingleValueMap()
MultiValueMap
MultiValueMap
.
toSingleValueMap
in interface MultiValueMap<String,String>
public int size()
size
in interface Map<String,List<String>>
public boolean isEmpty()
isEmpty
in interface Map<String,List<String>>
public boolean containsKey(Object key)
containsKey
in interface Map<String,List<String>>
public boolean containsValue(Object value)
containsValue
in interface Map<String,List<String>>
public List<String> get(Object key)
get
in interface Map<String,List<String>>
public List<String> put(String key, List<String> value)
put
in interface Map<String,List<String>>
public List<String> remove(Object key)
remove
in interface Map<String,List<String>>
public void putAll(Map<? extends String,? extends List<String>> m)
putAll
in interface Map<String,List<String>>
public void clear()
clear
in interface Map<String,List<String>>
public Set<String> keySet()
keySet
in interface Map<String,List<String>>
public Collection<List<String>> values()
values
in interface Map<String,List<String>>
public Set<Map.Entry<String,List<String>>> entrySet()
entrySet
in interface Map<String,List<String>>
public boolean equals(Object other)
equals
in interface Map<String,List<String>>
equals
in class Object
public int hashCode()
hashCode
in interface Map<String,List<String>>
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |