Browse Source

Copy header values instead of header lists in DefaultClientRequestBuilder

This commit changes the `headers(HttpHeaders)` method in
DefaultClientRequestBuilder so that it copies the individual header
values instead of using the `List<String>` value directly. The reason
for this change is that the list of values can be immutable, and adding
additional values after that could result in
UnsupportedOperationExceptions.
pull/1364/merge
Arjen Poutsma 8 years ago
parent
commit
510436bae9
  1. 7
      spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java

7
spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilder.java

@ -73,7 +73,12 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder { @@ -73,7 +73,12 @@ class DefaultClientRequestBuilder implements ClientRequest.Builder {
@Override
public ClientRequest.Builder headers(HttpHeaders headers) {
this.headers.putAll(headers);
for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
String headerName = entry.getKey();
for (String headerValue : entry.getValue()) {
this.headers.add(headerName, headerValue);
}
}
return this;
}

Loading…
Cancel
Save