Do not 500 if the content-length is not provided when uploading media. (#8862)
Instead return the proper 400 error.pull/8891/head
parent
112f6bd49e
commit
df3e6a23a7
|
@ -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 New Issue