Skip to content

Commit

Permalink
correctly handle rejected websocket connections in Tornado (Fixes #114)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Jun 3, 2019
1 parent b27cafb commit 51f5ad2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion engineio/async_drivers/tornado.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,12 @@ def make_response(status, headers, payload, environ):
mode.
"""
tornado_handler = environ['tornado.handler']
tornado_handler.set_status(int(status.split()[0]))
try:
tornado_handler.set_status(int(status.split()[0]))
except RuntimeError: # pragma: no cover
# for websocket connections Tornado does not accept a response, since
# it already emitted the 101 status code
return
for header, value in headers:
tornado_handler.set_header(header, value)
tornado_handler.write(payload)
Expand Down

0 comments on commit 51f5ad2

Please sign in to comment.