File tree 2 files changed +13
-2
lines changed
main/java/org/springframework/http
test/java/org/springframework/http
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -436,8 +436,11 @@ public HttpHeaders(MultiValueMap<String, String> headers) {
436
436
if (headers == EMPTY ) {
437
437
this .headers = CollectionUtils .toMultiValueMap (new LinkedCaseInsensitiveMap <>(8 , Locale .ENGLISH ));
438
438
}
439
- else if (headers instanceof ReadOnlyHttpHeaders readOnlyHttpHeaders ) {
440
- this .headers = readOnlyHttpHeaders .headers ;
439
+ else if (headers instanceof HttpHeaders httpHeaders ) {
440
+ while (httpHeaders .headers instanceof HttpHeaders wrapped ) {
441
+ httpHeaders = wrapped ;
442
+ }
443
+ this .headers = httpHeaders .headers ;
441
444
}
442
445
else {
443
446
this .headers = headers ;
Original file line number Diff line number Diff line change @@ -69,6 +69,14 @@ void constructorUnwrapsReadonly() {
69
69
assertThat (writable .getContentType ()).isEqualTo (MediaType .TEXT_PLAIN );
70
70
}
71
71
72
+ @ Test
73
+ void writableHttpHeadersUnwrapsMultiple () {
74
+ HttpHeaders originalExchangeHeaders = HttpHeaders .readOnlyHttpHeaders (new HttpHeaders ());
75
+ HttpHeaders firewallHeaders = new HttpHeaders (originalExchangeHeaders );
76
+ HttpHeaders writeable = new HttpHeaders (firewallHeaders );
77
+ writeable .setContentType (MediaType .APPLICATION_JSON );
78
+ }
79
+
72
80
@ Test
73
81
void getOrEmpty () {
74
82
String key = "FOO" ;
You can’t perform that action at this time.
0 commit comments