Skip to content

Commit

Permalink
HttpHeaders.writableHttpHeaders properly handles HttpHeaders.EMPTY
Browse files Browse the repository at this point in the history
Issue: SPR-17633
  • Loading branch information
jhoeller committed Jan 7, 2019
1 parent 1faeeae commit 6e3f974
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1694,11 +1694,15 @@ public static HttpHeaders readOnlyHttpHeaders(HttpHeaders headers) {
}

/**
* Return a {@code HttpHeaders} object that can read and written to.
* Return a {@code HttpHeaders} object that can be read and written to.
* @since 5.1.1
*/
public static HttpHeaders writableHttpHeaders(HttpHeaders headers) {
Assert.notNull(headers, "HttpHeaders must not be null");
if (headers instanceof ReadOnlyHttpHeaders) {
if (headers == EMPTY) {
return new HttpHeaders();
}
else if (headers instanceof ReadOnlyHttpHeaders) {
return new HttpHeaders(headers.headers);
}
else {
Expand Down

0 comments on commit 6e3f974

Please sign in to comment.