Browse Source

Simplify HttpHeaders(HttpHeaders) constructor

pull/35808/head
Sam Brannen 1 month ago
parent
commit
a54618b498
  1. 12
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java

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

@ -477,15 +477,9 @@ public class HttpHeaders implements Serializable { @@ -477,15 +477,9 @@ public class HttpHeaders implements Serializable {
*/
public HttpHeaders(HttpHeaders httpHeaders) {
Assert.notNull(httpHeaders, "HttpHeaders must not be null");
if (httpHeaders == EMPTY) {
this.headers = CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH));
}
else {
while (httpHeaders.headers instanceof HttpHeaders wrapped) {
httpHeaders = wrapped;
}
this.headers = httpHeaders.headers;
}
this.headers = (httpHeaders == EMPTY ?
CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH)) :
unwrap(httpHeaders));
}
/**

Loading…
Cancel
Save