diff --git a/Cargo.toml b/Cargo.toml index bcedfca4..03b691c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,12 @@ include = [ ] [dependencies] -bytes = "0.5" +bytes = "0.6" futures-core = { version = "0.3", default-features = false } futures-channel = "0.3" futures-util = { version = "0.3", default-features = false } http = "0.2" -http-body = "0.3.1" +http-body = { git = "https://github.com/hyperium/http-body" } httpdate = "0.3" httparse = "1.0" h2 = { git = "https://github.com/hyperium/h2", optional = true } @@ -63,7 +63,7 @@ tokio = { version = "0.3", features = [ "test-util", ] } tokio-test = "0.3" -tokio-util = { version = "0.4", features = ["codec"] } +tokio-util = { version = "0.5", features = ["codec"] } tower-util = "0.3" url = "1.0" diff --git a/examples/client_json.rs b/examples/client_json.rs index 63dc4bff..5bb585b9 100644 --- a/examples/client_json.rs +++ b/examples/client_json.rs @@ -4,7 +4,7 @@ #[macro_use] extern crate serde_derive; -use bytes::buf::BufExt as _; +use bytes::Buf as _; use hyper::Client; // A simple type alias so as to DRY. diff --git a/examples/web_api.rs b/examples/web_api.rs index bc9e1378..5226249b 100644 --- a/examples/web_api.rs +++ b/examples/web_api.rs @@ -1,6 +1,6 @@ #![deny(warnings)] -use bytes::buf::BufExt; +use bytes::Buf; use futures_util::{stream, StreamExt}; use hyper::client::HttpConnector; use hyper::service::{make_service_fn, service_fn}; diff --git a/src/body/to_bytes.rs b/src/body/to_bytes.rs index 4cce7857..8dfbe01c 100644 --- a/src/body/to_bytes.rs +++ b/src/body/to_bytes.rs @@ -23,7 +23,7 @@ where let second = if let Some(buf) = body.data().await { buf? } else { - return Ok(first.to_bytes()); + return Ok(first.copy_to_bytes(first.bytes().len())); }; // With more than 1 buf, we gotta flatten into a Vec first. diff --git a/src/proto/h1/encode.rs b/src/proto/h1/encode.rs index 9a80c8f3..d165527e 100644 --- a/src/proto/h1/encode.rs +++ b/src/proto/h1/encode.rs @@ -1,7 +1,7 @@ use std::fmt; use std::io::IoSlice; -use bytes::buf::ext::{BufExt, Chain, Take}; +use bytes::buf::{Chain, Take}; use bytes::Buf; use super::io::WriteBuf; diff --git a/src/proto/h1/io.rs b/src/proto/h1/io.rs index bfe1c4c3..04dcfbcc 100644 --- a/src/proto/h1/io.rs +++ b/src/proto/h1/io.rs @@ -3,6 +3,7 @@ use std::cmp; use std::fmt; use std::io::{self, IoSlice}; use std::marker::Unpin; +use std::mem::MaybeUninit; use bytes::{Buf, BufMut, Bytes, BytesMut}; use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; @@ -191,7 +192,10 @@ where if self.read_buf_remaining_mut() < next { self.read_buf.reserve(next); } - let mut buf = ReadBuf::uninit(&mut self.read_buf.bytes_mut()[..]); + + let dst = self.read_buf.bytes_mut(); + let dst = unsafe { &mut *(dst as *mut _ as *mut [MaybeUninit]) }; + let mut buf = ReadBuf::uninit(dst); match Pin::new(&mut self.io).poll_read(cx, &mut buf) { Poll::Ready(Ok(_)) => { let n = buf.filled().len();