Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http_interop: Implement
Request
conversion for http::request::Parts
I found the current conversion for `http::request::Builder` to be rather useless when the `http` crate and various crates providing `http` interfaces like `oauth2` are designed to provide an `http::Request` directly, and there being no way to convert from a `http::Request` back into its `http::request::Builder`. That, together with strange infallible defaults instead of providing `TryFrom` make the current implementation cumbersome to use. Fortunately `http` provides `http::Request::into_parts()` to get back a `Parts` structure (which is wrapped in `Result<>` inside `http::request::Builder` as sole member!) together with the request body (a generic type) which the user can manually pass to `send_string()`, `send_bytes()` or `call()` if there's no data. Implement a `From<http::request::Parts> for ureq::Request` to support this case, making `ureq` finally capable of sending `http::Request`s. (Note that, despite exclusively consisting of `Result<Parts>`, `http::request::Builder` has no constructor from `Ok(Parts {..})` which would have also facilitated this use-case somewhat)
- Loading branch information