Merge branch '6.1.x'

This commit is contained in:
Brian Clozel 2024-10-25 10:55:00 +02:00
commit 9df4fcdc9e
2 changed files with 13 additions and 2 deletions

View File

@ -436,8 +436,11 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
if (headers == EMPTY) {
this.headers = CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH));
}
else if (headers instanceof ReadOnlyHttpHeaders readOnlyHttpHeaders) {
this.headers = readOnlyHttpHeaders.headers;
else if (headers instanceof HttpHeaders httpHeaders) {
while (httpHeaders.headers instanceof HttpHeaders wrapped) {
httpHeaders = wrapped;
}
this.headers = httpHeaders.headers;
}
else {
this.headers = headers;

View File

@ -69,6 +69,14 @@ class HttpHeadersTests {
assertThat(writable.getContentType()).isEqualTo(MediaType.TEXT_PLAIN);
}
@Test
void writableHttpHeadersUnwrapsMultiple() {
HttpHeaders originalExchangeHeaders = HttpHeaders.readOnlyHttpHeaders(new HttpHeaders());
HttpHeaders firewallHeaders = new HttpHeaders(originalExchangeHeaders);
HttpHeaders writeable = new HttpHeaders(firewallHeaders);
writeable.setContentType(MediaType.APPLICATION_JSON);
}
@Test
void getOrEmpty() {
String key = "FOO";