Quote ETag if not quoted in HttpHeaders#setETag

This aligns HttpHeaders with other places like ServletWebRequest and
DefaultWebExchange where an ETag is accepted as input.

It also allows us to remove quoting from places that delegate to
HttpHeaders#setETag since it now does that internally.

Closes gh-33412
This commit is contained in:
rstoyanchev
2024-09-10 09:01:30 +01:00
parent 3dd4a8350a
commit 19700d07b1
9 changed files with 24 additions and 34 deletions

View File

@@ -214,15 +214,15 @@ class HttpHeadersTests {
}
@Test
void illegalETagWithoutQuotes() {
String eTag = "v2.6";
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag));
void eTagWithoutQuotes() {
headers.setETag("v2.6");
assertThat(headers.getETag()).isEqualTo("\"v2.6\"");
}
@Test
void illegalWeakETagWithoutLeadingQuote() {
String etag = "W/v2.6\"";
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(etag));
void weakETagWithoutLeadingQuote() {
headers.setETag("W/v2.6\"");
assertThat(headers.getETag()).isEqualTo("\"W/v2.6\"\"");
}
@Test