mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Make HttpEntity headers mutables
Since its inception, instantiating an `HttpEntity` makes its `HttpHeaders` read-only. While immutability is an interesting design principle, here we shouldn't enforce this. For example, developers can expect to instantiate a `ResponseEntity` and still mutate its headers. Closes gh-35888
This commit is contained in:
@@ -102,7 +102,7 @@ public class HttpEntity<T> {
|
||||
*/
|
||||
public HttpEntity(@Nullable T body, @Nullable HttpHeaders headers) {
|
||||
this.body = body;
|
||||
this.headers = HttpHeaders.readOnlyHttpHeaders(headers != null ? headers : new HttpHeaders());
|
||||
this.headers = (headers != null) ? headers : new HttpHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,8 +123,7 @@ public class HttpEntity<T> {
|
||||
*/
|
||||
@Deprecated(since = "7.0", forRemoval = true)
|
||||
public HttpEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers) {
|
||||
this.body = body;
|
||||
this.headers = HttpHeaders.readOnlyHttpHeaders(headers != null ? new HttpHeaders(headers) : new HttpHeaders());
|
||||
this(body, (headers != null) ? new HttpHeaders(headers) : new HttpHeaders());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user