matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Allow clients to specify additional HTTP headers

Open Johennes opened this issue 3 years ago • 1 comments

With #1078 we now have the ability to customize the user agent. Some clients may need to be able to specify other HTTP headers that they need to be present on every request sent to the home server. Element iOS, for instance, exposes an httpAdditionalHeaders build setting that is helpful for forks. Other clients may have similar requirements.

As far as I could tell, matrix-rust-sdk doesn't offer this option currently.

Johennes avatar Oct 06 '22 19:10 Johennes

Can you share more details on how this is helpful for forks? We recently discussed something similar and there were some concerns about allowing customization like this (it's a customization point that the Matrix spec itself never mentions, so depending on how it's used could lead to problems that look like SDK issues but aren't really).

jplatte avatar Oct 06 '22 20:10 jplatte

You can already specify a custom reqwest::Client using the http_client() method on the ClientBuilder: https://docs.rs/matrix-sdk/latest/matrix_sdk/struct.ClientBuilder.html#method.http_client

reqwest let's you set the default headers: https://docs.rs/reqwest/latest/reqwest/struct.ClientBuilder.html#method.default_headers

I don't think we need to do anything besides that.

poljar avatar Feb 02 '24 14:02 poljar