Skip to content

Commit

Permalink
Better HttpHeaders Copying (Azure#30860)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Sep 8, 2022
1 parent 7921e6f commit 2a4bfea
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public HttpHeaders(Iterable<HttpHeader> headers) {
}
}

HttpHeaders(HttpHeaders headers) {
this.headers = new HashMap<>((int) (headers.headers.size() / 0.75f));
// TODO (alzimmer): This, and the API above, should be copying using the value list as this will String
// join multiple values. Or, better yet provide better copy methods on HttpHeader and Header.
headers.headers.forEach((key, value) ->
this.headers.put(key, new HttpHeader(value.getName(), value.getValue())));
}

/**
* Create a HttpHeaders instance with an initial {@code size} empty headers
*
Expand Down

0 comments on commit 2a4bfea

Please sign in to comment.