Skip to content

MockHttpServletResponse.setDateHeader does not perform date formatting [SPR-11912] #16531

@spring-projects-issues

Description

@spring-projects-issues

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

  1. One possible fix would be to provide a getDateHeader accessor.
  2. 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:

Referenced from: commits 43e36e2

0 votes, 7 watchers

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions