-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
I am trying to test a servlet filter passing it an instance of MockHttpServletResponse
.
The filter attempts to overwrite existing Set-Cookie
headers with a new Set-Cookie
header calling the response.setHeader
method. This works on Jetty and Tomcat, however it does not work on the MockHttpServletResponse
- leading my tests to fail.
The MockHttpServletResponse
actually adds a new Set-Cookie
header when using the setHeader
method - possibly in contradiction to the HttpServletResponse
interface contract.
From inspection, it appears the setSpecialHeader
method contains a treatment of Set-Cookie
which other container implementations do not have. In other containers e.g. Jetty or Tomcat, the set of special headers is limited to Content-Type
or Content-Length
. In the MockHttpServletResponse
, the set of special headers also contains Language
and Set-Cookie
(see line 589) - which then leads to the Set-Cookie
header to be added, rather than replaced.
This difference means I can not test the behavior of my filter in a way consistent with how it will be deployed.