Closed darkgallium closed 3 years ago
To add some context, this problem appeared between @darkgallium dentrite instance and our synapse instance.
We use Traefik v1.7 in front of our synapse instance. Traefik defaults to dynamically compressing all contents, including media, if the client says it supports compression. When content is dynamically compressed by Traefik, the content-length
header is not sent.
Maybe Dendrite should not rely on this header or stop sending an header that says it supports compression?
As a quick fix, I am aware that we can simply configure Traefik to stop doing compression on our media even if supported by the client.
Background information
go version
: go1.15.2 linux/armDescription
When sending pictures from a federated synapse instance onto a public room of my dendrite server, the picture doesn't show up and when clicking on it we get the following JSON error :
Some clues
Problem seems to be located at the following line : https://github.com/matrix-org/dendrite/blob/e3c2b081c7c197cad931d6525931dc9e960b93c3/mediaapi/routing/download.go#L696
The header
Content-Length
seems to be missing from the HTTP response provided by the Synapse instance. Note that the problem doesn't appear with several other instances behind reverse proxies, which is not the case of the one I'm mentioning.Since the problem did not appear between instances of Synapse, I looked at Synapse's way of downloading pictures from federated instances and it effectively doesn't appear to use the
Content-Length
header to deduce file size (see https://github.com/matrix-org/synapse/blob/v1.21.0/synapse/rest/media/v1/media_repository.py#L332 and https://github.com/matrix-org/synapse/blob/1c262431f9bf768d106bf79a568479fa5a0784a1/synapse/http/matrixfederationclient.py#L939)Should I report this problem in the Synapse repo as well? I can possibly come up with a PR, just need some advice on what should be done.
Thanks for your help :)