-
Notifications
You must be signed in to change notification settings - Fork 476
Description
Description
Synapse REQUIRES the Content-Length to be set when uploading media, which is against the spec, which says that only Content-Type is required, and only on version 1.11 and under
Why this is actually an issue:
- Content-Length is a protected header in web browsers, which mean it cannot be configured
- Uploading streamed/generated content is quite important for lowering memory usage
The encrypted attachment spec uses AES-CTR, which [I assume] was picked because it can be multi-threaded, thus it can be streamed, this can let a user specify a file, and start uploading the file while streaming the encryption, without pre-computing and without needing to load the entire file into memory, however POST'ing streams in web doesn't set a Content-Length, and since it's a protected header it can't be set manually.
This is also a problem with streaming the uploads of generated content such as video or audio streams which you realistically don't want to retain in-memory, but upload them on the fly.
Steps to reproduce
- send an authorized POST to /_matrix/media/v3/upload without a Content-Length header
- see instant error
Homeserver
matrix.org
Synapse Version
{"server_version":"1.148.0rc1 (b=matrix-org-hotfixes-priv,047f4e920c)"}
Installation Method
I don't know
Database
matrix.org so unsure
Workers
I don't know
Platform
matrix.org so unsure
Configuration
No response
Relevant log output
-/-Anything else that would be useful to know?
IMHO the best way to solve this is to make the header optional, rather than required