mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 12:33:49 +01:00
Do not 500 if the content-length is not provided when uploading media. (#8862)
Instead return the proper 400 error.
This commit is contained in:
parent
112f6bd49e
commit
df3e6a23a7
2 changed files with 2 additions and 1 deletions
1
changelog.d/8862.bugfix
Normal file
1
changelog.d/8862.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fix a longstanding bug where a 500 error would be returned if the `Content-Length` header was not provided to the upload media resource.
|
|
@ -44,7 +44,7 @@ class UploadResource(DirectServeJsonResource):
|
|||
requester = await self.auth.get_user_by_req(request)
|
||||
# TODO: The checks here are a bit late. The content will have
|
||||
# already been uploaded to a tmp file at this point
|
||||
content_length = request.getHeader(b"Content-Length").decode("ascii")
|
||||
content_length = request.getHeader("Content-Length")
|
||||
if content_length is None:
|
||||
raise SynapseError(msg="Request must specify a Content-Length", code=400)
|
||||
if int(content_length) > self.max_upload_size:
|
||||
|
|
Loading…
Reference in a new issue