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.
This commit is contained in:
Arjen Poutsma 2017-06-07 17:55:51 +02:00
parent a0bce618c2
commit 510436bae9
1 changed files with 6 additions and 1 deletions

View File

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