0
0
Fork 1
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:
Patrick Cloke 2020-12-04 10:26:09 -05:00 committed by GitHub
parent 112f6bd49e
commit df3e6a23a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

1
changelog.d/8862.bugfix Normal file
View 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.

View file

@ -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: