Browse Source

Simplify HttpHeaders constructor

As of gh-33913, `HttpHeaders` does not implement the `MultiValueMap`
contract anymore, so we can take this opportunity to simplify one of the
constructors to not consider that the argument could be an `HttpHeaders`
instance. This case is already covered by the other constructor.

See gh-33913
pull/34380/head
Brian Clozel 12 months ago
parent
commit
e8f71ab5ef
  1. 13
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java

13
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -455,18 +455,7 @@ public class HttpHeaders implements Serializable { @@ -455,18 +455,7 @@ public class HttpHeaders implements Serializable {
*/
public HttpHeaders(MultiValueMap<String, String> headers) {
Assert.notNull(headers, "MultiValueMap must not be null");
if (headers == EMPTY) {
this.headers = CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH));
}
else if (headers instanceof HttpHeaders httpHeaders) {
while (httpHeaders.headers instanceof HttpHeaders wrapped) {
httpHeaders = wrapped;
}
this.headers = httpHeaders.headers;
}
else {
this.headers = headers;
}
this.headers = headers;
}
/**

Loading…
Cancel
Save