1tgr / rust-websocket-lite

A fast, low-overhead WebSocket client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: specify extra headers when connecting

mcseemk opened this issue · comments

Some WS servers require extra headers to be set at upgrade connection request (like Authorization , etc). Currently there is no way to specify them.

One way to do it would be to add something like add_header(name: String, value: String) method to ClientBuilder to create a vec or hashmap of extra headers which will then be added to the upgrade request by build_request() function.

Agree, I think it can live as a Vec<(String, String)> inside ClientBuilder. We're not treating ClientBuilder as performance sensitive so Vec allocation and String cloning is OK here.

There are types for HTTP headers more sophisticated than pairs of strings, but I don't think there's a strong need to use them here.

Closed by #15.