Ottomata has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/329689 )

Change subject: Specify charset in Content-Type header
......................................................................

Specify charset in Content-Type header

Some libraries (properly) default to using Latin 1 instead of utf-8
if charset is not specified.  We always use utf-8.

Change-Id: I4c564aa6c374b801ec93361cdb773487a1946553
---
M routes/v2.js
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/eventstreams 
refs/changes/89/329689/1

diff --git a/routes/v2.js b/routes/v2.js
index a0037b5..59c0bd1 100644
--- a/routes/v2.js
+++ b/routes/v2.js
@@ -23,6 +23,14 @@
  * This function only exists to DRY route creation below.
  */
 function eventStream(req, res, topics) {
+    // All of our data is utf-8 encoded.  Make the client expect this.
+    // The sse library that kafka-sse uses does not specify a charset in the
+    // Content-Type Header.  Some client libraries (like python requests)
+    // properly follow 
https://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
+    // and default to using ISO-8859-1 (Latin 1) when no charset is given, so
+    // we need to make sure we provide one here.
+    res.setHeader('Content-Type', 'text/event-stream; charset=utf-8');
+
     return kafkaSse(req, res, topics, {
         // Using topics for allowedTopics may seem redundant, but it
         // prevents requests for /stream/streamA from consuming from topics

-- 
To view, visit https://gerrit.wikimedia.org/r/329689
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c564aa6c374b801ec93361cdb773487a1946553
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/eventstreams
Gerrit-Branch: master
Gerrit-Owner: Ottomata <ao...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to