sbstp / attohttpc

Rust lightweight HTTP 1.1 client

Home Page:https://docs.rs/attohttpc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support 'basic_auth' on platforms other than Linux

pedorro opened this issue · comments

Just want to start by saying thanks for building this crate - it's exactly what I need to make simple, synchronous http requests.

Question about the 'basic_auth' function of RequestBuilder - currently (v0.20.0) it is only supported on Linux:
https://docs.rs/attohttpc/latest/attohttpc/struct.RequestBuilder.html#method.basic_auth

Is there a reason for this limitation? Can it be removed? It's really just adding a header, so there doesn't seem to be any technical reason why this wouldn't work on all platforms. (FWIW - for now I'm just adding my own 'basic_auth_creds' trait to RequestBuilder that adds this header, and it works just fine an all my target platforms - Linux, MacOS, Windows).

Thanks :)

The reason behind this is that it needs base64-encode the credentials which we do using the openssl crate to avoid additional dependencies, but that crate is used only on the Linux platform.

The limitation could be removed if we accept an additional (optional) dependency on a crate that computes base64.

hmm... interesting point.
For my work-around I'm including a dependency on a separate base64 crate - https://crates.io/crates/base64. Would that be an option here?

I think it is certainly an option, especially since that crate is widely used, well maintained and stable.

All good by me if someone has the time to implement it!

Excellent! Thanks all 😊