diff --git a/Cargo.toml b/Cargo.toml index 3b979a98..2a9c3934 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -127,7 +127,7 @@ futures = "0.3" h2 = { version = "0.4", features = [ "legacy", "stream" ] } handlebars = "3.0" hex = "0.4.3" -hyper = { version = "0.14", features = [ "full" ] } +hyper = { version = "0.14", features = [ "backports", "deprecated", "full" ] } libc = "0.2" log = "0.4.17" nix = "0.26.1" diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs index 978173a5..8a89031c 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -8,7 +8,7 @@ use hyper::client::{Client, HttpConnector}; use hyper::http::header::HeaderValue; use hyper::http::Uri; use hyper::http::{Request, Response}; -use hyper::Body; +use hyper::{body::HttpBody, Body}; use openssl::{ ssl::{SslConnector, SslMethod}, x509::X509StoreContextRef, @@ -706,8 +706,7 @@ impl HttpClient { .map(|_| Err(format_err!("unknown error"))) .await? } else { - resp.into_body() - .map_err(Error::from) + futures::TryStreamExt::map_err(resp.into_body(), Error::from) .try_fold(output, move |acc, chunk| async move { acc.write_all(&chunk)?; Ok::<_, Error>(acc) @@ -844,7 +843,7 @@ impl HttpClient { async fn api_response(response: Response) -> Result { let status = response.status(); - let data = hyper::body::to_bytes(response.into_body()).await?; + let data = HttpBody::collect(response.into_body()).await?.to_bytes(); let text = String::from_utf8(data.to_vec()).unwrap(); if status.is_success() { diff --git a/pbs-client/src/vsock_client.rs b/pbs-client/src/vsock_client.rs index 38823b54..5c18c6f3 100644 --- a/pbs-client/src/vsock_client.rs +++ b/pbs-client/src/vsock_client.rs @@ -7,7 +7,7 @@ use hyper::client::connect::{Connected, Connection}; use hyper::client::Client; use hyper::http::Uri; use hyper::http::{Request, Response}; -use hyper::Body; +use hyper::{body::HttpBody, Body}; use pin_project_lite::pin_project; use serde_json::Value; use tokio::io::{AsyncRead, AsyncWrite, AsyncWriteExt, ReadBuf}; @@ -179,8 +179,7 @@ impl VsockClient { if !status.is_success() { Self::api_response(resp).await.map(|_| ())? } else { - resp.into_body() - .map_err(Error::from) + futures::TryStreamExt::map_err(resp.into_body(), Error::from) .try_fold(output, move |acc, chunk| async move { acc.write_all(&chunk).await?; Ok::<_, Error>(acc) @@ -192,7 +191,7 @@ impl VsockClient { async fn api_response(response: Response) -> Result { let status = response.status(); - let data = hyper::body::to_bytes(response.into_body()).await?; + let data = HttpBody::collect(response.into_body()).await?.to_bytes(); let text = String::from_utf8(data.to_vec()).unwrap(); if status.is_success() { diff --git a/src/acme/client.rs b/src/acme/client.rs index d28ab3eb..97f628e3 100644 --- a/src/acme/client.rs +++ b/src/acme/client.rs @@ -6,7 +6,7 @@ use std::os::unix::fs::OpenOptionsExt; use anyhow::{bail, format_err}; use bytes::Bytes; -use hyper::{Body, Request}; +use hyper::{body::HttpBody, Body, Request}; use nix::sys::stat::Mode; use serde::{Deserialize, Serialize}; @@ -508,9 +508,11 @@ impl AcmeClient { let (parts, body) = response.into_parts(); let status = parts.status.as_u16(); - let body = hyper::body::to_bytes(body) + let body = body + .collect() .await - .map_err(|err| Error::Custom(format!("failed to retrieve response body: {}", err)))?; + .map_err(|err| Error::Custom(format!("failed to retrieve response body: {}", err)))? + .to_bytes(); let got_nonce = if let Some(new_nonce) = parts.headers.get(proxmox_acme::REPLAY_NONCE) { let new_nonce = new_nonce.to_str().map_err(|err| { diff --git a/src/api2/backup/mod.rs b/src/api2/backup/mod.rs index 82c6438a..efc97a1f 100644 --- a/src/api2/backup/mod.rs +++ b/src/api2/backup/mod.rs @@ -239,14 +239,12 @@ fn upgrade_to_backup_protocol( .and_then(move |conn| { env2.debug("protocol upgrade done"); - let mut http = hyper::server::conn::Http::new() - .with_executor(ExecInheritLogContext); - http.http2_only(true); + let mut http = hyper::server::conn::http2::Builder::new(ExecInheritLogContext); // increase window size: todo - find optiomal size let window_size = 32 * 1024 * 1024; // max = (1 << 31) - 2 - http.http2_initial_stream_window_size(window_size); - http.http2_initial_connection_window_size(window_size); - http.http2_max_frame_size(4 * 1024 * 1024); + http.initial_stream_window_size(window_size); + http.initial_connection_window_size(window_size); + http.max_frame_size(4 * 1024 * 1024); let env3 = env2.clone(); http.serve_connection(conn, service).map(move |result| { diff --git a/src/api2/reader/mod.rs b/src/api2/reader/mod.rs index 328141c8..1713f182 100644 --- a/src/api2/reader/mod.rs +++ b/src/api2/reader/mod.rs @@ -183,14 +183,12 @@ fn upgrade_to_backup_reader_protocol( let conn = hyper::upgrade::on(Request::from_parts(parts, req_body)).await?; env2.debug("protocol upgrade done"); - let mut http = - hyper::server::conn::Http::new().with_executor(ExecInheritLogContext); - http.http2_only(true); + let mut http = hyper::server::conn::http2::Builder::new(ExecInheritLogContext); // increase window size: todo - find optiomal size let window_size = 32 * 1024 * 1024; // max = (1 << 31) - 2 - http.http2_initial_stream_window_size(window_size); - http.http2_initial_connection_window_size(window_size); - http.http2_max_frame_size(4 * 1024 * 1024); + http.initial_stream_window_size(window_size); + http.initial_connection_window_size(window_size); + http.max_frame_size(4 * 1024 * 1024); http.serve_connection(conn, service) .map_err(Error::from)