INT-3063: 'Expires' HTTP header workaround

According to RFC 2616 HTTP clients should ignore invalid values
for date-aware header, but Spring MVC `HttpHeaders` raises
`IllegalArgumentException` in this case.
Proposal fix to Spring Integration just to `try...catch` call of
`HttpHeaders.getExpires()` and `return null`.

JIRA: https://jira.springsource.org/browse/INT-3063
This commit is contained in:
Artem Bilan
2013-06-15 14:49:18 +03:00
committed by Gary Russell
parent 70886b2543
commit 83046fcb39
2 changed files with 23 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ import org.springframework.util.CollectionUtils;
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gunnar Hillert
* @author Artem Bilan
* @since 2.0.1
*/
public class DefaultHttpHeaderMapperFromMessageOutboundTests {
@@ -658,4 +659,13 @@ public class DefaultHttpHeaderMapperFromMessageOutboundTests {
mapper.fromHeaders(new MessageHeaders(messageHeaders), headers);
assertNull(headers.get("Content-Length"));
}
@Test
public void testInt3063InvalidExpiresHeader() {
HttpHeaders headers = new HttpHeaders();
headers.set("Expires", "-1");
Map<String, Object> messageHeaders = DefaultHttpHeaderMapper.outboundMapper().toHeaders(headers);
assertEquals(0, messageHeaders.size());
}
}