ResponseEntity's HeadersBuilder allows for specifying existing HttpHeaders

Issue: SPR-12324
This commit is contained in:
Juergen Hoeller 2014-10-13 17:22:27 +02:00
parent 97596fb9f6
commit 8760be7d64
1 changed files with 16 additions and 1 deletions

View File

@ -256,13 +256,22 @@ public class ResponseEntity<T> extends HttpEntity<T> {
/**
* Add the given, single header value under the given name.
* @param headerName the header name
* @param headerName the header name
* @param headerValues the header value(s)
* @return this builder
* @see HttpHeaders#add(String, String)
*/
B header(String headerName, String... headerValues);
/**
* Copy the given headers into the entity's headers map.
* @param headers the existing HttpHeaders to copy from
* @return this builder
* @since 4.1.2
* @see HttpHeaders#add(String, String)
*/
B headers(HttpHeaders headers);
/**
* Set the set of allowed {@link HttpMethod HTTP methods}, as specified
* by the {@code Allow} header.
@ -360,6 +369,12 @@ public class ResponseEntity<T> extends HttpEntity<T> {
return this;
}
@Override
public BodyBuilder headers(HttpHeaders headers) {
this.headers.putAll(headers);
return this;
}
@Override
public BodyBuilder allow(HttpMethod... allowedMethods) {
this.headers.setAllow(new HashSet<HttpMethod>(Arrays.asList(allowedMethods)));