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

use hyperium/http instead of http-rs/http-types #128

Merged
merged 17 commits into from
Nov 30, 2023

Conversation

flisky
Copy link
Contributor

@flisky flisky commented Sep 16, 2023

Fix #123

Please attention: the exported types Method / HeaderValues make this a breaking change.

By the way, hyper v1.0 will remove hyper::Body, but I think it's fine to keep it for now?


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Cargo.toml Outdated Show resolved Hide resolved
@flisky
Copy link
Contributor Author

flisky commented Sep 22, 2023

friendly ping

@LukeMathWalker
Copy link
Owner

friendly ping

Friendly tip: never, ever, do this on an OSS project tracker 😄

I review PRs when I have the capacity to, pinging me doesn't make me review it any sooner.

@jplatte
Copy link

jplatte commented Oct 4, 2023

friendly ping

Friendly tip: never, ever, do this on an OSS project tracker 😄

While I agree that the above ping 2d after the last update was not very helpful, as a maintainer of many projects I want to note that forgetting about a PR is a thing I've been glad that people pinged me after a few weeks of inactivity on multiple occasions.

src/matchers.rs Outdated Show resolved Hide resolved
src/matchers.rs Outdated
}
values.into_iter().all(|value| self.1.contains(&value))
Copy link
Owner

Choose a reason for hiding this comment

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

This has a different semantic compared to the previous one: this is order-insensitive, while the previous implementation was order-sensitive.

src/mock.rs Outdated Show resolved Hide resolved
@LukeMathWalker
Copy link
Owner

friendly ping

Friendly tip: never, ever, do this on an OSS project tracker 😄

While I agree that the above ping 2d after the last update was not very helpful, as a maintainer of many projects I want to note that forgetting about a PR is a thing I've been glad that people pinged me after a few weeks of inactivity on multiple occasions.

A few weeks is fine, but 2 days is not—I don't even ping co-workers that soon 😅

Copy link

@jplatte jplatte left a comment

Choose a reason for hiding this comment

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

Not sure how useful an external review is, but apart from the header matching that I haven't dug into, this looks good to me. Only have two very minor comments.

src/request.rs Outdated
pub(crate) async fn from_hyper(request: hyper::Request<hyper::Body>) -> Request {
let (parts, body) = request.into_parts();
let method = parts.method.into();
let (method, headers) = (parts.method, parts.headers);
Copy link

Choose a reason for hiding this comment

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

Just my 2c, I'd do this as two statements.

pub(crate) fn generate_response(&self) -> Response {
let mut response = Response::new(self.status_code);
pub(crate) fn generate_response(&self) -> Response<Body> {
let mut response = Response::default();
Copy link

Choose a reason for hiding this comment

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

The Response::builder API should make this code a bit shorter.

src/respond.rs Outdated
@@ -75,7 +75,7 @@ use crate::{Request, ResponseTemplate};
/// `Respond` that propagates back a request header in the response:
///
/// ```rust
/// use http_types::headers::HeaderName;
/// use hyper::header::HeaderName;
Copy link
Owner

Choose a reason for hiding this comment

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

Can't we import from http here? I don't think we need to import from hyper.

Copy link

@jplatte jplatte Nov 3, 2023

Choose a reason for hiding this comment

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

I think it would require an extra (dev) dependency. (not to say that's not worth it)

Copy link
Owner

@LukeMathWalker LukeMathWalker Nov 3, 2023

Choose a reason for hiding this comment

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

It would, but http is already in our (non-dev) dependency tree, so it doesn't make an actual difference.

Copy link

Choose a reason for hiding this comment

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

Yeah, just one more version to keep in sync with the test in the manifest.

@LukeMathWalker
Copy link
Owner

This looks good to go, just some conflicts to resolve—thanks for the work!
I want to wait for hyper to push 1.0 out before merging and releasing this though.

@LukeMathWalker
Copy link
Owner

Both hyper and http cut 1.0—let's update and then we can merge and release!

@flisky
Copy link
Contributor Author

flisky commented Nov 16, 2023

Glad to hear! Will give it a try on this weekends.

@flisky
Copy link
Contributor Author

flisky commented Nov 18, 2023

So here is the hyper v1 upgrade.

However, I have to use a multi-threaded runtime to run the tests (see my last commit).
The spawn_local is just not scheduled at all even for a single testcase.(It's okay if I use tokio::net::TcpListener from top to down.)
I take hours to investigate, but no clue. Could you give some sight, please? @LukeMathWalker @jplatte Thanks!

@LukeMathWalker
Copy link
Owner

I discovered a while ago that converting a std TcpListener into a tokio TcpListener won't set it to non-blocking. I wonder if that's the issue here?

@flisky
Copy link
Contributor Author

flisky commented Nov 19, 2023

Yes, it's exactly the problem! I push another commit to switch back to single-thread runtime, thanks!

src/http.rs Outdated Show resolved Hide resolved
src/matchers.rs Outdated Show resolved Hide resolved
src/request.rs Outdated Show resolved Hide resolved
src/response_template.rs Outdated Show resolved Hide resolved
@LukeMathWalker LukeMathWalker merged commit 8047af3 into LukeMathWalker:main Nov 30, 2023
4 of 5 checks passed
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

Successfully merging this pull request may close these issues.

http-types dependency seems unmaintained
3 participants