Enforce UTF-8 response encoding in SseEmitter

This commit sets the response content type to
"text/event-stream;charset=UTF-8". Even if the SSE spec says that the
encoding should always be UTF-8 and that specifying the charset is
optional, we're setting it in all cases, since some containers might use
the default encoding "ISO-8859-1" and confuse HTTP clients.

Issue: SPR-14407
This commit is contained in:
Brian Clozel
2016-06-27 17:05:31 +02:00
parent 15c96b8efd
commit a25c43f695
2 changed files with 6 additions and 4 deletions

View File

@@ -148,7 +148,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests {
assertTrue(this.request.isAsyncStarted());
assertEquals(200, this.response.getStatus());
assertEquals("text/event-stream", this.response.getContentType());
assertEquals("text/event-stream;charset=UTF-8", this.response.getContentType());
SimpleBean bean1 = new SimpleBean();
bean1.setId(1L);
@@ -178,7 +178,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests {
assertTrue(this.request.isAsyncStarted());
assertEquals(200, this.response.getStatus());
assertEquals("text/event-stream", this.response.getContentType());
assertEquals("text/event-stream;charset=UTF-8", this.response.getContentType());
assertEquals("bar", this.response.getHeader("foo"));
}