-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Consider using http::{Request, Response}
for easier conversion
#236
Comments
For completeness, unfortunately |
Hey @MarijnS95, My concern with using That said, implementing Thoughts? |
I wouldn't be too afraid of that happening. Both of the structs seem to solely map what's in a HTTP request/response (method, uri, version, headers, response code, body), plus an If a client-implementer does care about an extension, they could insert/extract one before/after going down into the HTTP client implementation? If that's something you want to avoid at all costs, I believe we could implement those Regardless I started replacing the types last week just to see what it'd look like (don't remember, would have to check if this is the most recent push): One significant difference is the use of the |
I'm leaning toward accepting this change at the same time as #237 since they both require a major version bump. After looking closely at I also don't think we need to wait for
This is less than ideal, but probably not a blocker. In particular, having to use |
The diff linked above should compile now for most/all backends, but I still have to:
For now a version bump should not be needed, we can incorporate both as separate PRs (but land them in the same breaking |
One other breaking change I think we should make in the same release is to define |
I've started merging breaking changes into |
Previously, this crate defined its own `HttpRequest`/`HttpResponse` types and used `Fn` traits to define the HTTP client interfaces. This change replaces the `HttpRequest` and `HttpResponse` structs with type aliases to use `http::Request` and `http::Response`, respectively (#236). It also replaces the `Fn`-based interface with new `AsyncHttpClient` and `SyncHttpClient` traits. The corresponding `http_client` and `async_http_client` implementations (for `reqwest`, `curl`, and `ureq`) are replaced with trait implementations on stateful clients, where available. For example, `AsyncHttpClient` is now implemented for `reqwest::Client`, which allows connection reuse between requests. For convenience, these traits are also implemented for `Fn` types to support custom clients without requiring an explicit trait implementation. BREAKING CHANGES:
Previously, this crate defined its own `HttpRequest`/`HttpResponse` types and used `Fn` traits to define the HTTP client interfaces. This change replaces the `HttpRequest` and `HttpResponse` structs with type aliases to use `http::Request` and `http::Response`, respectively (#236). It also replaces the `Fn`-based interface with new `AsyncHttpClient` and `SyncHttpClient` traits. The corresponding `http_client` and `async_http_client` implementations (for `reqwest`, `curl`, and `ureq`) are replaced with trait implementations on stateful clients, where available. For example, `AsyncHttpClient` is now implemented for `reqwest::Client`, which allows connection reuse between requests. For convenience, these traits are also implemented for `Fn` types to support custom clients without requiring an explicit trait implementation. BREAKING CHANGES:
This is now released in 5.0.0-alpha.1. If you can, please try it out and let me know if you find any issues that should be fixed before stabilizing the 5.0 API. There's an Upgrade Guide to help. |
Turns out this assumption doesn't always hold (seanmonstar/reqwest#668), but the |
The
http
crate was added in 398d3a2, at which point theHttpRequest
andHttpResponse
types are mostly built up fromhttp
types. Would it be (un)reasonable to switch tohttp
Request
andResponse
types entirely? This, in addition to being a more commonly used type, already has builtin conversions forureq
andreqwest
:algesten/ureq#669
https://docs.rs/reqwest/latest/reqwest/struct.Request.html#impl-TryFrom%3CRequest%3CT%3E%3E-for-Request
But perhaps I am overlooking some shortcomings with the
http
types that make this infeasible? Thanks for considering this at least (and for the record, I'm willing to help out with the conversion)!I could not find
http
conversions for thecurl
crate, unfortunately.The text was updated successfully, but these errors were encountered: