Skip to content

Commit

Permalink
Force charset to UTF-8 (#14)
Browse files Browse the repository at this point in the history
UTF-8 Encoding is required for event streams per spec (https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events). However, if you're running node behind a Tomcat server, the default content is set to iso-8859-1. This will throw an error in Chrome. Since UTF-8 is required, I think setting it should be part of the library.
  • Loading branch information
willyboy authored and rexxars committed Feb 10, 2017
1 parent 4a3df66 commit 18557e7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/sse-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function initializeConnection(opts) {
opts.request.socket.setNoDelay(true);
opts.request.socket.setKeepAlive(true);
opts.response.writeHead(200, {
'Content-Type': 'text/event-stream',
'Content-Type': 'text/event-stream;charset=UTF-8',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive'
});
Expand Down

0 comments on commit 18557e7

Please sign in to comment.