relay: deliver EventSource as utf-8

This allows the client (requests.py) to produce unicode fields and
lines, instead of binary, which is necessary for py3 compatibility.
This commit is contained in:
Brian Warner 2015-09-23 18:31:17 -07:00
parent 2b37c62150
commit e8626fcea2

View File

@ -80,7 +80,7 @@ class Channel(resource.Resource):
if "text/event-stream" not in (request.getHeader("accept") or ""):
request.setResponseCode(http.BAD_REQUEST, "Must use EventSource")
return "Must use EventSource (Content-Type: text/event-stream)"
request.setHeader("content-type", "text/event-stream")
request.setHeader("content-type", "text/event-stream; charset=utf-8")
ep = EventsProtocol(request)
ep.sendEvent(json.dumps(self.welcome), name="welcome")
handle = (their_side, their_msgnum, ep)