ramosbugs / oauth2-rs

Extensible, strongly-typed Rust OAuth2 client library
Apache License 2.0
939 stars 163 forks source link

Why not using Response and Request of http::crate directly instead of aliasing it to HttpResponse and HttpRequest? It causes mismatch type error #254

Closed LorenzoLeonardo closed 8 months ago

LorenzoLeonardo commented 8 months ago

image

LorenzoLeonardo commented 8 months ago

They are the same crate using http::Request v1.0.0 but it will cause in this error.

LorenzoLeonardo commented 8 months ago

image

LorenzoLeonardo commented 8 months ago

the cause of error is the http::Request becomes oauth2::http::Request when aliasing it into HttpRequest even they are using the same http v1.0.0 crate

ramosbugs commented 8 months ago

This crate isn't using http 1.0 yet (see #237) but will before 5.0 is stabilized. This error is caused by a mismatch between the http version used in your Cargo.toml and the one used in oauth2. When writing a custom HTTP client, it's safest to use the oauth2::http re-export, which guarantees version parity. If your Cargo.toml version matches, then either import will work. I don't think this is a problem with the crate.

LorenzoLeonardo commented 8 months ago

Ahh ok. Thanks for the information. I thought it was now using http 1.0

LorenzoLeonardo commented 8 months ago

I was testing the v5.0.0.-alpha of this crate I thought it is now using the http 1.0. Thanks

ramosbugs commented 8 months ago

np, thanks for testing the new release! I should have an updated one and corresponding openidconnect release out soon

ramosbugs commented 8 months ago

btw to answer your question in the title about why they're type aliases, it's because the body type is generic, and this crate always uses Vec<u8> as the body type, which is set in the type aliases: https://github.com/ramosbugs/oauth2-rs/blob/1fc8188b22eaa055d3eca748964fca5876a448e2/src/endpoint.rs#L16-L20

LorenzoLeonardo commented 8 months ago

@ramosbugs let me know what alpha release that you will release next to version up the http from 0.2 to 1.0.0. Thank very much

ramosbugs commented 8 months ago

The upgrade is blocked on seanmonstar/reqwest#2039, but if you subscribe to #237 I'll post there when it's released