-
Couldn't load subscription status.
- Fork 38.8k
Description
Samuel Halliday opened SPR-11912 and commented
Status Quo
HttpServletResponse.setDateHeader takes a long parameter and is supposed to set the HTTP header as a string in RFC 2616 format.
However, the setDateHeader and addDateHeader methods in MockHttpServletResponse simply save the supplied long value as-is. For example, MockHttpServletResponse.getHeader("Last-Modified") will return 0L and not the RFC formatted string.
This makes it impossible to use this mock to test behavior in date header fields.
Proposals
- One possible fix would be to provide a
getDateHeaderaccessor. - Another option would be to immediately convert date headers to formatted strings when they are added or set and store the formatted strings instead of longs.
The same goes for the request side: please provide a setDateHeader method in MockHttpServletRequest.
Affects: 3.1.4
Issue Links:
- MockHttpServletRequest does not handle rfc formatted dates. [SPR-12056] #16672 MockHttpServletRequest does not handle rfc formatted dates. ("is duplicated by")
- MockHttpServletRequest and MockHttpServletResponse should re-use date patterns / parsers / formatters from HttpHeaders [SPR-16312] #20859 MockHttpServletRequest and MockHttpServletResponse should re-use date patterns / parsers / formatters from HttpHeaders
- Add a new ResultMatcher for date formats in HTTP headers [SPR-13263] #17854 Add a new ResultMatcher for date formats in HTTP headers
Referenced from: commits 43e36e2
0 votes, 7 watchers