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

Fix 'NoneType' object has no attribute 'writeHeaders' #2796

Merged
merged 2 commits into from
Jan 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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