diff --git a/Cargo.toml b/Cargo.toml
index 7f0a6e31..272bcc18 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,7 +29,7 @@ futures-util-preview = { version = "0.3.0-alpha.17" }
http = "0.1.15"
http-body = "0.1"
httparse = "1.0"
-h2 = "0.1.10"
+h2 = { git = "https://github.com/hyperium/h2" }
iovec = "0.1"
itoa = "0.4.1"
log = "0.4"
diff --git a/benches/end_to_end.rs b/benches/end_to_end.rs
index d16a9563..59679e3d 100644
--- a/benches/end_to_end.rs
+++ b/benches/end_to_end.rs
@@ -64,18 +64,14 @@ fn http1_parallel_x10_req_10mb(b: &mut test::Bencher) {
}
#[bench]
-#[ignore]
fn http2_get(b: &mut test::Bencher) {
- // FIXME: re-implement tests when `h2` upgrades to `async/await`
opts()
.http2()
.bench(b)
}
#[bench]
-#[ignore]
fn http2_post(b: &mut test::Bencher) {
- // FIXME: re-implement tests when `h2` upgrades to `async/await`
opts()
.http2()
.method(Method::POST)
@@ -84,9 +80,7 @@ fn http2_post(b: &mut test::Bencher) {
}
#[bench]
-#[ignore]
fn http2_req_100kb(b: &mut test::Bencher) {
- // FIXME: re-implement tests when `h2` upgrades to `async/await`
let body = &[b'x'; 1024 * 100];
opts()
.http2()
@@ -96,9 +90,7 @@ fn http2_req_100kb(b: &mut test::Bencher) {
}
#[bench]
-#[ignore]
fn http2_parallel_x10_empty(b: &mut test::Bencher) {
- // FIXME: re-implement tests when `h2` upgrades to `async/await`
opts()
.http2()
.parallel(10)
@@ -106,9 +98,7 @@ fn http2_parallel_x10_empty(b: &mut test::Bencher) {
}
#[bench]
-#[ignore]
fn http2_parallel_x10_req_10mb(b: &mut test::Bencher) {
- // FIXME: re-implement tests when `h2` upgrades to `async/await`
let body = &[b'x'; 1024 * 1024 * 10];
opts()
.http2()
diff --git a/src/body/body.rs b/src/body/body.rs
index 388dccb4..3671930c 100644
--- a/src/body/body.rs
+++ b/src/body/body.rs
@@ -269,25 +269,17 @@ impl Body {
}
None => Poll::Ready(None),
}
- }
+ },
Kind::H2 {
- /*recv: ref mut h2,*/ ..
- } => {
- unimplemented!("h2.poll_inner");
- /*
- h2
- .poll()
- .map(|r#async| {
- r#async.map(|opt| {
- opt.map(|bytes| {
- let _ = h2.release_capacity().release_capacity(bytes.len());
- Chunk::from(bytes)
- })
- })
- })
- .map_err(crate::Error::new_body)
- */
- }
+ recv: ref mut h2, ..
+ } => match ready!(Pin::new(&mut *h2).poll_next(cx)) {
+ Some(Ok(bytes)) => {
+ let _ = h2.release_capacity().release_capacity(bytes.len());
+ Poll::Ready(Some(Ok(Chunk::from(bytes))))
+ },
+ Some(Err(e)) => Poll::Ready(Some(Err(crate::Error::new_body(e)))),
+ None => Poll::Ready(None),
+ },
Kind::Wrapped(ref mut s) => {
match ready!(s.as_mut().poll_next(cx)) {
Some(res) => Poll::Ready(Some(res.map_err(crate::Error::new_body))),
@@ -314,11 +306,12 @@ impl Payload for Body {
self.poll_eof(cx)
}
- fn poll_trailers(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll