Improve MockHttpServletRequest/Response charset parsing
Issue: SPR-12677
This commit is contained in:
@@ -100,6 +100,17 @@ public class MockHttpServletRequestTests {
|
||||
assertEquals("UTF-8", request.getCharacterEncoding());
|
||||
}
|
||||
|
||||
// SPR-12677
|
||||
|
||||
@Test
|
||||
public void setContentTypeHeaderWithMoreComplexCharsetSyntax() {
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foo=bar";
|
||||
request.addHeader("Content-Type", contentType);
|
||||
assertEquals(contentType, request.getContentType());
|
||||
assertEquals(contentType, request.getHeader("Content-Type"));
|
||||
assertEquals("UTF-8", request.getCharacterEncoding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setContentTypeThenCharacterEncoding() {
|
||||
request.setContentType("test/plain");
|
||||
|
||||
@@ -90,6 +90,23 @@ public class MockHttpServletResponseTests {
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
}
|
||||
|
||||
// SPR-12677
|
||||
|
||||
@Test
|
||||
public void contentTypeHeaderWithMoreComplexCharsetSyntax() {
|
||||
String contentType = "test/plain;charset=\"utf-8\";foo=\"charset=bar\";foocharset=bar;foo=bar";
|
||||
response.setHeader("Content-Type", contentType);
|
||||
assertEquals(contentType, response.getContentType());
|
||||
assertEquals(contentType, response.getHeader("Content-Type"));
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
|
||||
response = new MockHttpServletResponse();
|
||||
response.addHeader("Content-Type", contentType);
|
||||
assertEquals(contentType, response.getContentType());
|
||||
assertEquals(contentType, response.getHeader("Content-Type"));
|
||||
assertEquals("UTF-8", response.getCharacterEncoding());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setContentTypeThenCharacterEncoding() {
|
||||
response.setContentType("test/plain");
|
||||
|
||||
Reference in New Issue
Block a user