mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-24 07:39:24 -05:00
add M_TOO_LARGE error code for uploading a too large file (#6151)
Fixes #6109
This commit is contained in:
parent
ea7d938bca
commit
474abf1eb6
1
changelog.d/6109.bugfix
Normal file
1
changelog.d/6109.bugfix
Normal 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.
|
@ -17,7 +17,7 @@ import logging
|
|||||||
|
|
||||||
from twisted.web.server import NOT_DONE_YET
|
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 (
|
from synapse.http.server import (
|
||||||
DirectServeResource,
|
DirectServeResource,
|
||||||
respond_with_json,
|
respond_with_json,
|
||||||
@ -56,7 +56,11 @@ class UploadResource(DirectServeResource):
|
|||||||
if content_length is None:
|
if content_length is None:
|
||||||
raise SynapseError(msg="Request must specify a Content-Length", code=400)
|
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(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)
|
upload_name = parse_string(request, b"filename", encoding=None)
|
||||||
if upload_name:
|
if upload_name:
|
||||||
|
Loading…
Reference in New Issue
Block a user