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:
@@ -134,14 +134,12 @@ public class ResponseEntityTests {
|
||||
|
||||
@Test
|
||||
public void headers() throws URISyntaxException {
|
||||
String eTag = "\"foo\"";
|
||||
URI location = new URI("location");
|
||||
long contentLength = 67890;
|
||||
MediaType contentType = MediaType.TEXT_PLAIN;
|
||||
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.ok().
|
||||
allow(HttpMethod.GET).
|
||||
eTag(eTag).
|
||||
lastModified(12345L).
|
||||
location(location).
|
||||
contentLength(contentLength).
|
||||
@@ -153,7 +151,6 @@ public class ResponseEntityTests {
|
||||
HttpHeaders responseHeaders = responseEntity.getHeaders();
|
||||
|
||||
assertEquals("GET", responseHeaders.getFirst("Allow"));
|
||||
assertEquals(eTag, responseHeaders.getFirst("ETag"));
|
||||
assertEquals("Thu, 01 Jan 1970 00:00:12 GMT",
|
||||
responseHeaders.getFirst("Last-Modified"));
|
||||
assertEquals(location.toASCIIString(),
|
||||
@@ -164,6 +161,19 @@ public class ResponseEntityTests {
|
||||
assertNull(responseEntity.getBody());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void Etagheader() throws URISyntaxException {
|
||||
|
||||
ResponseEntity<Void> responseEntity = ResponseEntity.ok().eTag("\"foo\"").build();
|
||||
assertEquals("\"foo\"", responseEntity.getHeaders().getETag());
|
||||
|
||||
responseEntity = ResponseEntity.ok().eTag("foo").build();
|
||||
assertEquals("\"foo\"", responseEntity.getHeaders().getETag());
|
||||
|
||||
responseEntity = ResponseEntity.ok().eTag("W/\"foo\"").build();
|
||||
assertEquals("W/\"foo\"", responseEntity.getHeaders().getETag());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headersCopy() {
|
||||
HttpHeaders customHeaders = new HttpHeaders();
|
||||
|
||||
Reference in New Issue
Block a user