Description
Chris DaMour opened SPR-15209 and commented
we index all our data by locale, and we have an edge service normalize the accept-language request header for the given request.
I was trying to test this with mock mvc using the default boot locale resolver that just uses accept-language request header, but it did not work as expected.
This appears to be because MockHttpServletRequestBuilder and MockHttpServletRequest do not interpret the Accept-Language header at any point when implementing getLocale(). Since getLocale() is kind of fundamental to java servlet & AcceptHeaderLocaleResolver depends on this fundamentalness since it doesn't actually check the Accept-Language header directly, i think the mockers should be a little more knowledgeable about such a header.
however, I'm not sure if these are intentionally dumb. at some point the special handling of the Content-Type request header was removed from MockHttpServletRequest and that is a very similar case.
I'm not super comfortable with relying on locale() in my mock builder as it's not really verifying the incoming accept-language header is what's being respected.
If there's some direction i should follow i'd submit a PR
Affects: 4.3.6
Issue Links:
- AcceptHeaderLocaleResolver should allow to define a default Locale [SPR-14312] #18884 AcceptHeaderLocaleResolver should allow to define a default Locale
- MockHttpServletResponse.setLocale(Locale) should set HttpHeaders.CONTENT_LANGUAGE header [SPR-16311] #20858 MockHttpServletResponse.setLocale(Locale) should set HttpHeaders.CONTENT_LANGUAGE header
- MockHttpServletResponse doesn't propagate Content-Language response header [SPR-17284] #21817 MockHttpServletResponse doesn't propagate Content-Language response header
- MockHttpServletRequest changes Accept-Language header values [SPR-17566] #22098 MockHttpServletRequest changes Accept-Language header values
- Update Cookie headers in MockHttpServletRequest and Response [SPR-15225] #19790 Update Cookie headers in MockHttpServletRequest and Response