[Question] How to add headers to connection?
mvniekerk opened this issue · 3 comments
Hi
I checked in the examples and API how to add headers to the initial HTTP connection, but could not find anything.
How would I add such?
Which API are you using to create the connection?
If you use one of the connect_async()
functions, note that it doesn't only take an URL as parameter: https://docs.rs/async-tungstenite/0.13.0/async_tungstenite/async_std/fn.connect_async.html . You can pass anything that implements IntoClientRequest
, including httparse:Request
and tungstenite::handshake::client::Request
(aka http::Request
), which both allow adding custom headers and allow any kind of customization of the request.
Thank you for the comment. I'm just up for any API or any example. I'll check if I can make do with the above
Let me know if you get stuck, and if you have an example that would also be great to include in the repo :)