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:
Brian Clozel
2015-08-22 15:29:19 +02:00
parent 2df3646e90
commit 88405be8a5
2 changed files with 21 additions and 3 deletions

View File

@@ -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;
}