Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan b601820b88 Update changelog 2020-11-10 12:14:36 +00:00
Andrew Morgan 02b703c7d8 Remove SynapseError substitutions 2020-11-10 12:11:08 +00:00
2 changed files with 3 additions and 4 deletions

View File

@ -1 +1 @@
Return `502` HTTP error code to the client instead of `500` when a remote server incorrectly sets the `Content-Type` header in response to a JSON request.
Improve the error message returned when a remote server incorrectly sets the `Content-Type` header in response to a JSON request.

View File

@ -1064,7 +1064,7 @@ def check_content_type_is_json(headers):
c_type = headers.getRawHeaders(b"Content-Type")
if c_type is None:
raise RequestSendFailed(
SynapseError(502, "No Content-Type header received from remote server"),
RuntimeError("No Content-Type header received from remote server"),
can_retry=False,
)
@ -1072,8 +1072,7 @@ def check_content_type_is_json(headers):
val, options = cgi.parse_header(c_type)
if val != "application/json":
raise RequestSendFailed(
SynapseError(
502,
RuntimeError(
"Remote server sent Content-Type header of '%s', not 'application/json'"
% c_type,
),