diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2020-11-11 14:22:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-11 14:22:40 +0000 |
commit | eedaf90c840f2b66e0cd537ccd462df19b3f5dcf (patch) | |
tree | 7ed796a14b55bb76a276db1ccd2abade85c318f2 /synapse | |
parent | Catch exceptions in password_providers (#8636) (diff) | |
download | synapse-eedaf90c840f2b66e0cd537ccd462df19b3f5dcf.tar.xz |
Better error message when a remote resource uses invalid Content-Type (#8719)
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/http/matrixfederationclient.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py index 04766ca965..7e17cdb73e 100644 --- a/synapse/http/matrixfederationclient.py +++ b/synapse/http/matrixfederationclient.py @@ -1063,13 +1063,19 @@ def check_content_type_is_json(headers): """ c_type = headers.getRawHeaders(b"Content-Type") if c_type is None: - raise RequestSendFailed(RuntimeError("No Content-Type header"), can_retry=False) + raise RequestSendFailed( + RuntimeError("No Content-Type header received from remote server"), + can_retry=False, + ) c_type = c_type[0].decode("ascii") # only the first header val, options = cgi.parse_header(c_type) if val != "application/json": raise RequestSendFailed( - RuntimeError("Content-Type not application/json: was '%s'" % c_type), + RuntimeError( + "Remote server sent Content-Type header of '%s', not 'application/json'" + % c_type, + ), can_retry=False, ) |