Handle null values in MockHttpServletResponse#setHeader

Prior to this commit, `MockHttpServletResponse#setHeader` would not
remove the header entry when given a `null` value, as documented in the
Servlet API.
This commit ensures that this behavior is enforced.

Fixes gh-34464
This commit is contained in:
Brian Clozel
2025-02-21 14:23:12 +01:00
parent 4606337180
commit 6dd73ae3e4
3 changed files with 24 additions and 2 deletions
@@ -686,7 +686,12 @@ public class MockHttpServletResponse implements HttpServletResponse {
@Override
public void setHeader(String name, @Nullable String value) {
setHeaderValue(name, value);
if (value == null) {
this.headers.remove(name);
}
else {
setHeaderValue(name, value);
}
}
@Override