Affects: 6.x+
It seems that if we provide multiple values for CONTENT_LANGUAGE
as an array like:
ResponseEntity.ok()
.header(HttpHeaders.CONTENT_LANGUAGE, contentLanguage.toArray(new String[0]))
.body(body);
It won't work nicely with MockHttpServletResponse
.
The logic we have there in setSpecialHeader
method:
https://github.com/spring-projects/spring-framework/blob/8b14bf86efd590247b2b6fd4843023ee283768d0/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java#L756-L767
expects that all the values are sent in a value
.
but from debugging, I saw that ServletServerHttpResponse
will call setSpecialHeader
of MockHttpServletResponse
for each header's value.
https://github.com/spring-projects/spring-framework/blob/8b14bf86efd590247b2b6fd4843023ee283768d0/spring-web/src/main/java/org/springframework/http/server/ServletServerHttpResponse.java#L113-L119
Thus, only the last value will be present in the response.
Comment From: bclozel
Thanks for the report @Romster this has been fixed for the next set of maintenance releases.
Comment From: Romster
Wow! That was fast! Thank you @bclozel !