0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-07-01 00:48:20 +02:00

add M_TOO_LARGE error code for uploading a too large file (#6151)

Fixes #6109
This commit is contained in:
Anshul Angaria 2019-10-08 18:25:16 +05:30 committed by Andrew Morgan
parent ea7d938bca
commit 474abf1eb6
2 changed files with 7 additions and 2 deletions

1
changelog.d/6109.bugfix Normal file
View file

@ -0,0 +1 @@
Fix bug when uploading a large file: Synapse responds with `M_UNKNOWN` while it should be `M_TOO_LARGE` according to spec. Contributed by Anshul Angaria.

View file

@ -17,7 +17,7 @@ import logging
from twisted.web.server import NOT_DONE_YET
from synapse.api.errors import SynapseError
from synapse.api.errors import Codes, SynapseError
from synapse.http.server import (
DirectServeResource,
respond_with_json,
@ -56,7 +56,11 @@ class UploadResource(DirectServeResource):
if content_length is None:
raise SynapseError(msg="Request must specify a Content-Length", code=400)
if int(content_length) > self.max_upload_size:
raise SynapseError(msg="Upload request body is too large", code=413)
raise SynapseError(
msg="Upload request body is too large",
code=413,
errcode=Codes.TOO_LARGE,
)
upload_name = parse_string(request, b"filename", encoding=None)
if upload_name: