Coder Social home page Coder Social logo

Why not using Response and Request of http::crate directly instead of aliasing it to HttpResponse and HttpRequest? It causes mismatch type error about oauth2-rs HOT 10 CLOSED

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024
Why not using Response and Request of http::crate directly instead of aliasing it to HttpResponse and HttpRequest? It causes mismatch type error

from oauth2-rs.

Comments (10)

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024

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

from oauth2-rs.

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024

image

from oauth2-rs.

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 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

from oauth2-rs.

ramosbugs avatar ramosbugs commented on July 30, 2024

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.

from oauth2-rs.

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024

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

from oauth2-rs.

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024

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

from oauth2-rs.

ramosbugs avatar ramosbugs commented on July 30, 2024

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

from oauth2-rs.

ramosbugs avatar ramosbugs commented on July 30, 2024

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>>;

from oauth2-rs.

LorenzoLeonardo avatar LorenzoLeonardo commented on July 30, 2024

@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

from oauth2-rs.

ramosbugs avatar ramosbugs commented on July 30, 2024

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

from oauth2-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.