File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
main/java/org/springframework/http
test/java/org/springframework/http Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -783,12 +783,14 @@ public long getDate() {
783
783
*/
784
784
public void setETag (String etag ) {
785
785
if (etag != null ) {
786
- Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/" ),
787
- "Invalid ETag: does not start with W/ or \" " );
788
- Assert . isTrue ( etag . endsWith ( " \" " ), "Invalid ETag: does not end with \" " );
786
+ Assert .isTrue (etag .startsWith ("\" " ) || etag .startsWith ("W/\" " ), "ETag does not start with W/ \" or \" " );
787
+ Assert . isTrue ( etag . endsWith ( " \" " ), " ETag does not end with \" " );
788
+ set ( ETAG , etag );
789
789
}
790
- set (ETAG , etag );
791
- }
790
+ else {
791
+ remove (ETAG );
792
+ }
793
+ }
792
794
793
795
/**
794
796
* Return the entity tag of the body, as specified by the {@code ETag} header.
Original file line number Diff line number Diff line change @@ -157,6 +157,12 @@ public void illegalETag() {
157
157
assertEquals ("Invalid ETag header" , "\" v2.6\" " , headers .getFirst ("ETag" ));
158
158
}
159
159
160
+ @ Test (expected = IllegalArgumentException .class )
161
+ public void illegalWeakETagWithoutLeadingQuote () {
162
+ String etag = "W/v2.6\" " ;
163
+ headers .setETag (etag );
164
+ }
165
+
160
166
@ Test
161
167
public void ifMatch () {
162
168
String ifMatch = "\" v2.6\" " ;
You can’t perform that action at this time.
0 commit comments