mirror of
https://mau.dev/maunium/synapse.git
synced 2024-10-01 01:36:05 -04:00
Merge pull request #2796 from matrix-org/rav/fix_closed_connection_errors
Fix 'NoneType' object has no attribute 'writeHeaders'
This commit is contained in:
commit
1954e867b4
@ -316,15 +316,6 @@ class JsonResource(HttpServer, resource.Resource):
|
|||||||
|
|
||||||
def _send_response(self, request, code, response_json_object,
|
def _send_response(self, request, code, response_json_object,
|
||||||
response_code_message=None):
|
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))
|
outgoing_responses_counter.inc(request.method, str(code))
|
||||||
|
|
||||||
# TODO: Only enable CORS for the requests that need it.
|
# TODO: Only enable CORS for the requests that need it.
|
||||||
@ -400,6 +391,15 @@ class RootRedirect(resource.Resource):
|
|||||||
def respond_with_json(request, code, json_object, send_cors=False,
|
def respond_with_json(request, code, json_object, send_cors=False,
|
||||||
response_code_message=None, pretty_print=False,
|
response_code_message=None, pretty_print=False,
|
||||||
version_string="", canonical_json=True):
|
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:
|
if pretty_print:
|
||||||
json_bytes = encode_pretty_printed_json(json_object) + "\n"
|
json_bytes = encode_pretty_printed_json(json_object) + "\n"
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user