Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2796 from matrix-org/rav/fix_closed_connection_er…
Browse files Browse the repository at this point in the history
…rors

Fix 'NoneType' object has no attribute 'writeHeaders'
  • Loading branch information
richvdh authored Jan 17, 2018
2 parents f23b407 + 11ab2f5 commit 1954e86
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions synapse/http/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,6 @@ def _async_render(self, request, request_metrics):

def _send_response(self, request, code, response_json_object,
response_code_message=None):
# could alternatively use request.notifyFinish() and flip a flag when
# the Deferred fires, but since the flag is RIGHT THERE it seems like
# a waste.
if request._disconnected:
logger.warn(
"Not sending response to request %s, already disconnected.",
request)
return

outgoing_responses_counter.inc(request.method, str(code))

# TODO: Only enable CORS for the requests that need it.
Expand Down Expand Up @@ -400,6 +391,15 @@ def getChild(self, name, request):
def respond_with_json(request, code, json_object, send_cors=False,
response_code_message=None, pretty_print=False,
version_string="", canonical_json=True):
# could alternatively use request.notifyFinish() and flip a flag when
# the Deferred fires, but since the flag is RIGHT THERE it seems like
# a waste.
if request._disconnected:
logger.warn(
"Not sending response to request %s, already disconnected.",
request)
return

if pretty_print:
json_bytes = encode_pretty_printed_json(json_object) + "\n"
else:
Expand Down

0 comments on commit 1954e86

Please sign in to comment.