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

upgrade hyper to v0.11 #151

Merged
merged 1 commit into from Jun 21, 2017
Merged

upgrade hyper to v0.11 #151

merged 1 commit into from Jun 21, 2017

Conversation

seanmonstar
Copy link
Owner

This adds a reqwest::unstable::async module that makes puts the reqwest API over hyper v0.11, but with futures and streams. The sync API is powered by the unstable async one. This should keep the sync API completely the same, with all features working.

The async module is available publicly only with features = ["unstable"] in your Cargo.toml, and then via reqwest::unstable::async. It may be worth considering how rayon handles unstable APIs, and possibly do likewise.

The async module may be missing some features. The gzip option does not work, as the libflate crate used internally cannot handle non-blocking IO yet. The Body stream may be barebones, while trying to decide the exact async body API.

@seanmonstar
Copy link
Owner Author

Woops, forgot I had disabled the timeout feature. Adding back in (with integration tests this time, so it's harder to forget next time).

Copy link
Contributor

@KodrAus KodrAus left a comment

Choose a reason for hiding this comment

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

I've just done a quick poke through the code and left some comments.

They're probably mostly just me being ignorant :) I did expect the synchronous layer to be a bit thinner, and confused myself with the async methods peppered around. Is the idea that the asynchronous Body is an implementation detail and you always work with the synchronous one?

Maybe adding a simple asynchronous post example would make that all clearer.

}
}

// pub(crate)
Copy link
Contributor

Choose a reason for hiding this comment

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

pub(crate) is stable now, right?

Copy link
Owner Author

Choose a reason for hiding this comment

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

On most recent version. It doesn't really cost anything to still compile on the previous version.

// pub(crate)

#[inline]
pub fn wrap(body: ::hyper::Body) -> Body {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to make these inherent methods?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yep, because they're pub(crate). Implementation details.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohhh. I actually totally misunderstood the // pub(crate) comment. I thought it was a reminder to make these pub(crate) once that feature was stable, not to say the following pub items are not part of the public API

}
}
}
}

pub fn can_reset(body: &Body) -> bool {
#[inline]
pub fn async(body: Body) -> (Option<Sender>, async_impl::Body, Option<u64>) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be public, since it's returning an unstable async Body?

Copy link
Owner Author

Choose a reason for hiding this comment

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

The body module isn't public, so these functions are pub(crate).

/// Relies on the `futures` crate, which is unstable, hence this module
/// is unstable.
pub mod async {
pub use ::async_impl::{
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also include RequestBuilder and Body?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Hm, yea, probably.

use futures::{Stream, Poll, Async};
use bytes::Bytes;

pub struct Body {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like a shame to lose some of the From conversions on the synchronous body when dealing with the asynchronous one directly.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Indeed, but asynchronous bodies need to be Stream, and that means File and Box<Read> and friends don't fit, yet. I wanted to get the upgrade done before figuring out all that.

@melroy89
Copy link

nice, I'm waiting for this :D!

@seanmonstar seanmonstar mentioned this pull request Jun 22, 2017
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.

None yet

3 participants