Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Http conversions #26

Merged
merged 2 commits into from
May 5, 2020
Merged

Conversation

mathstuf
Copy link
Contributor

@mathstuf mathstuf commented May 4, 2020


Depends on #25.

This allows reqwest_mock to be used with http-using APIs rather than
forcing the entire API stack to use the types in this crate.
@mathstuf mathstuf mentioned this pull request May 4, 2020
impl<T> From<HttpRequest<T>> for Request where T: Into<Body> {
fn from(r: HttpRequest<T>) -> Self {
let header = RequestHeader {
url: Url::parse(&format!("{}", r.uri())).unwrap(),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will merge your PR but I'll add a note here that this should be better handled in the future. (Invalid urls could be used as an exploit to make a software panic, but it's not like the crate is security oriented to begin with.)

Also see: seanmonstar/reqwest#668

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That issue is about the other direction, but I'd not be surprised if this way also had parsing disagreements. Unfortunately, there doesn't seem any work going on to make a unified url crate that http is willing to use (builder pattern in use, HTTP2 breakdown and relative path support), so we're stuck with these conversion warts.

hyperium/http#396 hyperium/http#277 (points to servo/rust-url#468) hyperium/http#137 hyperium/http#73

@leoschwarz leoschwarz merged commit 51ff918 into leoschwarz:master May 5, 2020
@mathstuf mathstuf deleted the http-conversions branch May 5, 2020 13:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants