Fixed #169: Don't try to send messages to a closed client

This commit is contained in:
Andrew Godwin 2018-02-14 14:52:49 -08:00
parent f53eb0dda6
commit de0811f13e

View File

@ -189,8 +189,13 @@ class WebRequest(http.Request):
""" """
Handles a reply from the client Handles a reply from the client
""" """
# Handle connections that are already closed
if self.channel is None:
return
# Check message validity
if "type" not in message: if "type" not in message:
raise ValueError("Message has no type defined") raise ValueError("Message has no type defined")
# Handle message
if message["type"] == "http.response.start": if message["type"] == "http.response.start":
if self._response_started: if self._response_started:
raise ValueError("HTTP response has already been started") raise ValueError("HTTP response has already been started")