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
This commit is contained in:
Brian Clozel 2025-02-06 14:37:16 +01:00
parent 2a846c9594
commit e8f71ab5ef
1 changed files with 1 additions and 12 deletions

View File

@ -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;
}
/**