1
0

Compare commits

...

2 Commits

Author SHA1 Message Date
Andrew Morgan 9f2434d494 Don't require Content-Length header 2020-01-09 17:01:55 +00:00
Andrew Morgan a6670b7257 Don't 500 on not providing a Content-Length header to media upload 2020-01-09 16:25:56 +00:00
+8 -9
View File
@@ -52,15 +52,14 @@ class UploadResource(DirectServeResource):
requester = await self.auth.get_user_by_req(request) requester = await self.auth.get_user_by_req(request)
# TODO: The checks here are a bit late. The content will have # TODO: The checks here are a bit late. The content will have
# already been uploaded to a tmp file at this point # already been uploaded to a tmp file at this point
content_length = request.getHeader(b"Content-Length").decode("ascii") if request.hasHeader(b"Content-Length"):
if content_length is None: content_length = request.getHeader(b"Content-Length").decode("ascii")
raise SynapseError(msg="Request must specify a Content-Length", code=400) if int(content_length) > self.max_upload_size:
if int(content_length) > self.max_upload_size: raise SynapseError(
raise SynapseError( msg="Upload request body is too large",
msg="Upload request body is too large", code=413,
code=413, errcode=Codes.TOO_LARGE,
errcode=Codes.TOO_LARGE, )
)
upload_name = parse_string(request, b"filename", encoding=None) upload_name = parse_string(request, b"filename", encoding=None)
if upload_name: if upload_name: