Fix multiple Content-Language values in MockHttpServletResponse

Prior to this commit, `MockHttpServletResponse` would only support
adding a `Content-Language` once. Adding multiple header values would
always replace the content-language property in the response and the
entire header value.

This commit ensures that this behavior is supported.

Fixes gh-34488
This commit is contained in:
Brian Clozel
2025-02-25 17:11:37 +01:00
parent aff9ac72ec
commit b6a5402d88
3 changed files with 32 additions and 18 deletions

View File

@@ -641,4 +641,12 @@ class MockHttpServletResponseTests {
assertThat(response.getContentAsString()).isEqualTo(content);
}
@Test // gh-34488
void shouldAddMultipleContentLanguage() {
response.addHeader("Content-Language", "en");
response.addHeader("Content-Language", "fr");
assertThat(response.getHeaders("Content-Language")).contains("en", "fr");
assertThat(response.getLocale()).isEqualTo(Locale.ENGLISH);
}
}