Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 opened this issue Mar 3, 2024 · 10 comments

Comments

@LorenzoLeonardo
Copy link
Contributor

image

@LorenzoLeonardo
Copy link
Contributor Author

LorenzoLeonardo commented Mar 3, 2024

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

@LorenzoLeonardo
Copy link
Contributor Author

image

@LorenzoLeonardo
Copy link
Contributor Author

LorenzoLeonardo commented Mar 3, 2024

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

@LorenzoLeonardo LorenzoLeonardo changed the title Error: Why not using Response and Request of http::crate directly instead of typing it to HttpResponse and HttpRequest? Why not using Response and Request of http::crate directly instead of aliasing it to HttpResponse and HttpRequest? It causes mismatch type error Mar 3, 2024
@ramosbugs
Copy link
Owner

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
Copy link
Contributor Author

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

@LorenzoLeonardo
Copy link
Contributor Author

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

@ramosbugs
Copy link
Owner

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

@ramosbugs ramosbugs closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2024
@ramosbugs
Copy link
Owner

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:

/// An HTTP request.
pub type HttpRequest = http::Request<Vec<u8>>;
/// An HTTP response.
pub type HttpResponse = http::Response<Vec<u8>>;

@LorenzoLeonardo
Copy link
Contributor Author

@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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants