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

Add a hyper client implementation #32

Merged
merged 7 commits into from
Aug 7, 2020
Merged

Add a hyper client implementation #32

merged 7 commits into from
Aug 7, 2020

Conversation

bspeice
Copy link
Contributor

@bspeice bspeice commented Jul 13, 2020

Given http-rs/async-h1#109, I don't think it's possible to add tokio as an executor for async-h1. Instead, we can add hyper as a client to the http-client facade, allowing for libraries built on top of http-client to be executor independent.

I still need to do come cleanup and testing, but I wanted to present the work thus far and ask:

  • Is this organization interested in supporting a tokio-based client?
  • If so, I could use some help clarifying some behavior (the most interesting bits are in HttpTypesResponse::try_from())

@bspeice
Copy link
Contributor Author

bspeice commented Jul 13, 2020

Also, opened the PR before noticing #1, but this should fix it.

@yoshuawuyts
Copy link
Member

Is this organization interested in supporting a tokio-based client?

I definitely am! -- I've had frustrating experiences with Hyper and Tokio in the past, to the point that I found it easier to work on a new HTTP stack and runtime. But if this is something that you'd be willing to implement and maintain, then it's most definitely welcome!

@bspeice
Copy link
Contributor Author

bspeice commented Jul 13, 2020

Glad to hear. I have some other libraries I'm working on, and the goal is to make sure that there's meaningful cross-executor support. Happy to help maintain this, I'll get it cleaned up this morning and post another comment once it's ready for a more thorough inspection.

@bspeice bspeice changed the title [WIP] Add a hyper client implementation Add a hyper client implementation Jul 13, 2020
@bspeice
Copy link
Contributor Author

bspeice commented Jul 13, 2020

This is ready for review once a maintainer has availability.

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

http-types has a hyperium-http feature that implements most of the conversions in this PR for you.

An overview of the conversions is here. I believe this covers most of it, but if we're missing something we can update http-types. That should cover some of the gnarlier bits of this PR (:

src/hyper.rs Outdated Show resolved Hide resolved
src/hyper.rs Outdated Show resolved Hide resolved
@bspeice
Copy link
Contributor Author

bspeice commented Jul 14, 2020

My concern with hyperium-http was that it would be enabled unconditionally. There's a nightly Cargo feature to conditionally enable features, but right now, adding hyperium-http means that all users (even those who don't use the hyper client) would need to compile the http crate. By re-implementing the conversions from hyper types (which are largely re-exports of http), you only compile http when necessary.

Long story short - happy to use hyperium-http and take advantage of the conversions, but there is a compile-time penalty for all non-hyper users.

@bspeice
Copy link
Contributor Author

bspeice commented Jul 14, 2020

Minor note after conversion: the header conversion functions aren't public and because of body type mis-matches they can't be accessed as part of the From<> conversions.

@bspeice bspeice requested a review from yoshuawuyts July 15, 2020 04:02
@bspeice
Copy link
Contributor Author

bspeice commented Jul 23, 2020

Just wanted to check - is there anything else that needs to be done here? To the best of my knowledge, this is ready for review/merge.

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

This looks great; thanks so much!

@yoshuawuyts yoshuawuyts merged commit a1043a5 into http-rs:master Aug 7, 2020
@bspeice bspeice mentioned this pull request Aug 9, 2020
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.

2 participants