Skip to content

Commit 98a9758

Browse files
committed
Enable deprecation warnings and address
1 parent 8f9bec2 commit 98a9758

6 files changed

Lines changed: 10 additions & 15 deletions

File tree

audio/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bytes = "1"
1919
ctr = "0.9"
2020
futures-core = "0.3"
2121
futures-util = "0.3"
22-
hyper = { version = "0.14", features = ["client"] }
22+
hyper = { version = "0.14", features = ["client", "backports", "deprecated"] }
2323
log = "0.4"
2424
parking_lot = { version = "0.12", features = ["deadlock_detection"] }
2525
tempfile = "3"

audio/src/fetch/receive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77

88
use bytes::Bytes;
99
use futures_util::StreamExt;
10-
use hyper::StatusCode;
10+
use hyper::{body::HttpBody, StatusCode};
1111
use tempfile::NamedTempFile;
1212
use tokio::sync::{mpsc, oneshot};
1313

@@ -97,7 +97,7 @@ async fn receive_data(
9797
}
9898

9999
let body = response.into_body();
100-
let data = match hyper::body::to_bytes(body).await {
100+
let data = match body.collect().await.map(|b| b.to_bytes()) {
101101
Ok(bytes) => bytes,
102102
Err(e) => break Err(e.into()),
103103
};

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ governor = { version = "0.6", default-features = false, features = ["std", "jitt
2626
hmac = "0.12"
2727
httparse = "1.7"
2828
http = "0.2"
29-
hyper = { version = "0.14", features = ["client", "http1", "http2", "tcp"] }
29+
hyper = { version = "0.14", features = ["client", "http1", "http2", "tcp", "backports", "deprecated"] }
3030
hyper-proxy = { version = "0.9", default-features = false, features = ["rustls"] }
3131
hyper-rustls = { version = "0.24", features = ["http2"] }
3232
log = "0.4"

core/src/http_client.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ use governor::{
1111
};
1212
use http::{header::HeaderValue, Uri};
1313
use hyper::{
14-
client::{HttpConnector, ResponseFuture},
15-
header::USER_AGENT,
16-
Body, Client, HeaderMap, Request, Response, StatusCode,
14+
body::HttpBody, client::{HttpConnector, ResponseFuture}, header::USER_AGENT, Body, Client, HeaderMap, Request, Response, StatusCode
1715
};
1816
use hyper_proxy::{Intercept, Proxy, ProxyConnector};
1917
use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder};
@@ -178,9 +176,7 @@ impl HttpClient {
178176
// As correct as that may be technically, we now need all this boilerplate to clone it
179177
// ourselves, as any `Request` is moved in the loop.
180178
let (parts, body) = req.into_parts();
181-
let body_as_bytes = hyper::body::to_bytes(body)
182-
.await
183-
.unwrap_or_else(|_| Bytes::new());
179+
let body_as_bytes = body.collect().await.map(|b| b.to_bytes()).unwrap_or_default();
184180

185181
loop {
186182
let mut req = Request::builder()
@@ -218,7 +214,7 @@ impl HttpClient {
218214

219215
pub async fn request_body(&self, req: Request<Body>) -> Result<Bytes, Error> {
220216
let response = self.request(req).await?;
221-
Ok(hyper::body::to_bytes(response.into_body()).await?)
217+
Ok(response.into_body().collect().await?.to_bytes())
222218
}
223219

224220
pub fn request_stream(&self, req: Request<Body>) -> Result<IntoStream<ResponseFuture>, Error> {

discovery/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ form_urlencoded = "1.0"
1818
futures-core = "0.3"
1919
futures-util = "0.3"
2020
hmac = "0.12"
21-
hyper = { version = "0.14", features = ["http1", "server", "tcp"] }
21+
hyper = { version = "0.14", features = ["http1", "server", "tcp", "backports", "deprecated"] }
2222
libmdns = "0.8"
2323
log = "0.4"
2424
rand = "0.8"

discovery/src/server.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ use futures_core::Stream;
1515
use futures_util::{FutureExt, TryFutureExt};
1616
use hmac::{Hmac, Mac};
1717
use hyper::{
18-
service::{make_service_fn, service_fn},
19-
Body, Method, Request, Response, StatusCode,
18+
body::HttpBody, service::{make_service_fn, service_fn}, Body, Method, Request, Response, StatusCode
2019
};
2120

2221
use log::{debug, error, warn};
@@ -219,7 +218,7 @@ impl RequestHandler {
219218
debug!("{:?} {:?} {:?}", parts.method, parts.uri.path(), params);
220219
}
221220

222-
let body = hyper::body::to_bytes(body).await?;
221+
let body = body.collect().await?.to_bytes();
223222

224223
params.extend(form_urlencoded::parse(&body));
225224

0 commit comments

Comments
 (0)