File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
main/java/org/springframework/http
test/java/org/springframework/http Expand file tree Collapse file tree 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) {
436436 if (headers == EMPTY ) {
437437 this .headers = CollectionUtils .toMultiValueMap (new LinkedCaseInsensitiveMap <>(8 , Locale .ENGLISH ));
438438 }
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 ;
441444 }
442445 else {
443446 this .headers = headers ;
Original file line number Diff line number Diff line change @@ -69,6 +69,14 @@ void constructorUnwrapsReadonly() {
6969 assertThat (writable .getContentType ()).isEqualTo (MediaType .TEXT_PLAIN );
7070 }
7171
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+
7280 @ Test
7381 void getOrEmpty () {
7482 String key = "FOO" ;
You can’t perform that action at this time.
0 commit comments