Skip to content

Commit a738d03

Browse files
committed
chore(dependencies): update to http-body 0.3
1 parent 4d7a226 commit a738d03

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ futures-core = { version = "0.3", default-features = false }
2525
futures-channel = "0.3"
2626
futures-util = { version = "0.3", default-features = false }
2727
http = "0.2"
28-
http-body = "0.2"
28+
http-body = "0.3"
2929
httparse = "1.0"
3030
h2 = "0.2"
3131
itoa = "0.4.1"
@@ -49,7 +49,7 @@ spmc = "0.3"
4949
serde = "1.0"
5050
serde_derive = "1.0"
5151
serde_json = "1.0"
52-
tokio = { version = "0.2.2", features = ["fs", "macros", "rt-util", "sync", "time", "test-util"] }
52+
tokio = { version = "0.2.2", features = ["fs", "macros", "io-std", "rt-util", "sync", "time", "test-util"] }
5353
tokio-test = "0.2"
5454
url = "1.0"
5555

benches/end_to_end.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl Opts {
319319
async {
320320
let res = fut.await.expect("client wait");
321321
let mut body = res.into_body();
322-
while let Some(_chunk) = body.next().await {}
322+
while let Some(_chunk) = body.data().await {}
323323
}
324324
};
325325

@@ -356,7 +356,7 @@ fn spawn_server(rt: &mut tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
356356
.serve(make_service_fn( move |_| async move {
357357
Ok::<_, hyper::Error>(service_fn(move |req: Request<Body>| async move {
358358
let mut req_body = req.into_body();
359-
while let Some(_chunk) = req_body.next().await {}
359+
while let Some(_chunk) = req_body.data().await {}
360360
Ok::<_, hyper::Error>(Response::new(Body::from(body)))
361361
}))
362362
}))

examples/client.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![deny(warnings)]
22
#![warn(rust_2018_idioms)]
33
use std::env;
4-
use std::io::{self, Write};
54

65
use hyper::{Client, body::HttpBody as _};
6+
use tokio::io::{self, AsyncWriteExt as _};
77

88
// A simple type alias so as to DRY.
99
type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
@@ -35,16 +35,14 @@ async fn main() -> Result<()> {
3535
async fn fetch_url(url: hyper::Uri) -> Result<()> {
3636
let client = Client::new();
3737

38-
let res = client.get(url).await?;
38+
let mut res = client.get(url).await?;
3939

4040
println!("Response: {}", res.status());
4141
println!("Headers: {:#?}\n", res.headers());
4242

43-
let mut body = res.into_body();
44-
45-
while let Some(next) = body.next().await {
43+
while let Some(next) = res.body_mut().data().await {
4644
let chunk = next?;
47-
io::stdout().write_all(&chunk)?;
45+
io::stdout().write_all(&chunk).await?;
4846
}
4947

5048
println!("\n\nDone!");

src/client/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//! // Concatenate the body stream into a single buffer...
4343
//! let mut body = res.into_body();
4444
//! let mut bytes = Vec::new();
45-
//! while let Some(next) = body.next().await {
45+
//! while let Some(next) = body.data().await {
4646
//! let chunk = next?;
4747
//! bytes.extend(chunk);
4848
//! }

tests/server.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ use tokio::runtime::Runtime;
2323
use tokio::io::{AsyncRead, AsyncWrite};
2424

2525
use hyper::{Body, Request, Response, StatusCode, Version};
26+
use hyper::body::HttpBody as _;
2627
use hyper::client::Client;
2728
use hyper::server::conn::Http;
2829
use hyper::server::Server;
@@ -1779,7 +1780,7 @@ impl tower_service::Service<Request<Body>> for TestService {
17791780
let replies = self.reply.clone();
17801781

17811782
Box::pin(async move {
1782-
while let Some(chunk) = hyper::body::HttpBody::next(req.body_mut()).await {
1783+
while let Some(chunk) = req.body_mut().data().await {
17831784
match chunk {
17841785
Ok(chunk) => {
17851786
tx.send(Msg::Chunk(chunk.to_vec())).unwrap();

0 commit comments

Comments
 (0)