Skip to content

Commit

Permalink
Merge pull request #170 from posita/posita/169-jsonrpchandler-content…
Browse files Browse the repository at this point in the history
…-type

READY FOR REVIEW - Fix #169. Set correct Content-Type for JSON-RPC responses.
  • Loading branch information
fiorix committed Jan 7, 2016
2 parents 8f8a7e1 + 9b94e74 commit 6ab75d8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cyclone/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def post(self, *args):
self._cbResult(AttributeError("method not found: %s" % method),
jsonid)

def set_default_headers(self):
self.set_header('Content-Type', 'application/json; charset=UTF-8')

def _cbResult(self, result, jsonid):
if isinstance(result, failure.Failure):
error = {'code': 0, 'message': str(result.value)}
Expand Down
1 change: 1 addition & 0 deletions cyclone/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ class BaseHandler(CustomErrorPageMixin, cyclone.web.RequestHandler):
self.write(line)
self.finish()
else:
self.set_header('Content-Type', 'text/html; charset=UTF-8')
self.finish("<html><title>%(code)d: %(message)s</title>"
"<body>%(code)d: %(message)s</body></html>" %
{"code": status_code, "message": self._reason})
Expand Down

0 comments on commit 6ab75d8

Please sign in to comment.