Fix HttpHeaders.setHost() to remove the header
See gh-33716
This commit is contained in:
@@ -1136,7 +1136,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||
set(HOST, value);
|
||||
}
|
||||
else {
|
||||
remove(HOST, null);
|
||||
remove(HOST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -213,6 +213,15 @@ class HttpHeadersTests {
|
||||
assertThat(headers.getFirst("Host")).as("Invalid Host header").isEqualTo("[::1]");
|
||||
}
|
||||
|
||||
@Test
|
||||
void hostDeletion() {
|
||||
InetSocketAddress host = InetSocketAddress.createUnresolved("localhost", 8080);
|
||||
headers.setHost(host);
|
||||
headers.setHost(null);
|
||||
assertThat(headers.getHost()).as("Host is not deleted").isEqualTo(null);
|
||||
assertThat(headers.getFirst("Host")).as("Host is not deleted").isEqualTo(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
void eTagWithoutQuotes() {
|
||||
headers.setETag("v2.6");
|
||||
|
||||
Reference in New Issue
Block a user