Skip to content

Commit

Permalink
Polishing contribution
Browse files Browse the repository at this point in the history
Closes gh-33374
  • Loading branch information
rstoyanchev committed Aug 13, 2024
1 parent 1703b71 commit fe4fd00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 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 @@ -1048,9 +1048,8 @@ public long getDate() {
*/
public void setETag(@Nullable String etag) {
if (etag != null) {
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""),
"Invalid ETag: does not start with W/\" or \"");
Assert.isTrue(etag.endsWith("\""), "Invalid ETag: does not end with \"");
Assert.isTrue(etag.startsWith("\"") || etag.startsWith("W/\""), "ETag does not start with W/\" or \"");
Assert.isTrue(etag.endsWith("\""), "ETag does not end with \"");
set(ETAG, etag);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ void ipv6Host() {
}

@Test
void illegalETag() {
void illegalETagWithoutQuotes() {
String eTag = "v2.6";
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(eTag));
}

@Test
void illegalETagWithoutQuoteAfterWSlash() {
void illegalWeakETagWithoutLeadingQuote() {
String etag = "W/v2.6\"";
assertThatIllegalArgumentException().as("Invalid Weak ETag").isThrownBy(() -> headers.setETag(etag));
assertThatIllegalArgumentException().isThrownBy(() -> headers.setETag(etag));
}

@Test
Expand Down

0 comments on commit fe4fd00

Please sign in to comment.