Quote ETags set with ResponseEntity builder API
Prior to this change, trying to set an unquoted ETag with `ResponseEntity`'s API would throw an `IllegalArgumentException`. This commit automatically quotes ETag values set using ResponseEntity. Issue: SPR-13378
This commit is contained in:
@@ -421,6 +421,14 @@ public class ResponseEntity<T> extends HttpEntity<T> {
|
||||
|
||||
@Override
|
||||
public BodyBuilder eTag(String eTag) {
|
||||
if (eTag != null) {
|
||||
if(!eTag.startsWith("\"") && !eTag.startsWith("W/\"")) {
|
||||
eTag = "\"" + eTag;
|
||||
}
|
||||
if(!eTag.endsWith("\"")) {
|
||||
eTag = eTag + "\"";
|
||||
}
|
||||
}
|
||||
this.headers.setETag(eTag);
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user