From 168ed370263e84a6235968c615b856b9280debe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 13 Mar 2025 11:34:30 +0100 Subject: [PATCH] h2: switch to legacy feature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit to avoid upgrading to hyper 1 / http 1 right now. this is a Debian/Proxmox specific workaround. Signed-off-by: Fabian Grünbichler --- Cargo.toml | 2 +- examples/h2client.rs | 6 +++--- examples/h2s-client.rs | 6 +++--- pbs-client/src/backup_writer.rs | 8 ++++---- pbs-client/src/http_client.rs | 12 +++++++----- pbs-client/src/pipe_to_stream.rs | 2 +- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9e1d99cb..3b979a98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,7 +124,7 @@ env_logger = "0.11" flate2 = "1.0" foreign-types = "0.3" futures = "0.3" -h2 = { version = "0.4", features = [ "stream" ] } +h2 = { version = "0.4", features = [ "legacy", "stream" ] } handlebars = "3.0" hex = "0.4.3" hyper = { version = "0.14", features = [ "full" ] } diff --git a/examples/h2client.rs b/examples/h2client.rs index 1dcb4498..e44c43fa 100644 --- a/examples/h2client.rs +++ b/examples/h2client.rs @@ -10,7 +10,7 @@ use tokio::net::TcpStream; // Simple H2 client to test H2 download speed using h2server.rs struct Process { - body: h2::RecvStream, + body: h2::legacy::RecvStream, trailers: bool, bytes: usize, } @@ -50,7 +50,7 @@ impl Future for Process { } fn send_request( - mut client: h2::client::SendRequest, + mut client: h2::legacy::client::SendRequest, ) -> impl Future> { println!("sending request"); @@ -78,7 +78,7 @@ async fn run() -> Result<(), Error> { let conn = TcpStream::connect(std::net::SocketAddr::from(([127, 0, 0, 1], 8008))).await?; conn.set_nodelay(true).unwrap(); - let (client, h2) = h2::client::Builder::new() + let (client, h2) = h2::legacy::client::Builder::new() .initial_connection_window_size(1024 * 1024 * 1024) .initial_window_size(1024 * 1024 * 1024) .max_frame_size(4 * 1024 * 1024) diff --git a/examples/h2s-client.rs b/examples/h2s-client.rs index a12b5a48..86b3a931 100644 --- a/examples/h2s-client.rs +++ b/examples/h2s-client.rs @@ -10,7 +10,7 @@ use tokio::net::TcpStream; // Simple H2 client to test H2 download speed using h2s-server.rs struct Process { - body: h2::RecvStream, + body: h2::legacy::RecvStream, trailers: bool, bytes: usize, } @@ -50,7 +50,7 @@ impl Future for Process { } fn send_request( - mut client: h2::client::SendRequest, + mut client: h2::legacy::client::SendRequest, ) -> impl Future> { println!("sending request"); @@ -94,7 +94,7 @@ async fn run() -> Result<(), Error> { .await .map_err(|err| format_err!("connect failed - {}", err))?; - let (client, h2) = h2::client::Builder::new() + let (client, h2) = h2::legacy::client::Builder::new() .initial_connection_window_size(1024 * 1024 * 1024) .initial_window_size(1024 * 1024 * 1024) .max_frame_size(4 * 1024 * 1024) diff --git a/pbs-client/src/backup_writer.rs b/pbs-client/src/backup_writer.rs index 1253ef56..32542506 100644 --- a/pbs-client/src/backup_writer.rs +++ b/pbs-client/src/backup_writer.rs @@ -56,7 +56,7 @@ pub struct UploadOptions { } struct ChunkUploadResponse { - future: h2::client::ResponseFuture, + future: h2::legacy::client::ResponseFuture, size: usize, } @@ -143,7 +143,7 @@ impl BackupWriter { param: Option, content_type: &str, data: Vec, - ) -> Result { + ) -> Result { let request = H2Client::request_builder("localhost", method, path, param, Some(content_type)) .unwrap(); @@ -514,7 +514,7 @@ impl BackupWriter { } fn response_queue() -> ( - mpsc::Sender, + mpsc::Sender, oneshot::Receiver>, ) { let (verify_queue_tx, verify_queue_rx) = mpsc::channel(100); @@ -537,7 +537,7 @@ impl BackupWriter { tokio::spawn( ReceiverStream::new(verify_queue_rx) .map(Ok::<_, Error>) - .try_for_each(move |response: h2::client::ResponseFuture| { + .try_for_each(move |response: h2::legacy::client::ResponseFuture| { response .map_err(Error::from) .and_then(H2Client::h2api_response) diff --git a/pbs-client/src/http_client.rs b/pbs-client/src/http_client.rs index 6b7cfae3..978173a5 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -791,7 +791,7 @@ impl HttpClient { let max_window_size = (1 << 31) - 2; - let (h2, connection) = h2::client::Builder::new() + let (h2, connection) = h2::legacy::client::Builder::new() .initial_connection_window_size(max_window_size) .initial_window_size(max_window_size) .max_frame_size(4 * 1024 * 1024) @@ -936,11 +936,11 @@ impl Drop for HttpClient { #[derive(Clone)] pub struct H2Client { - h2: h2::client::SendRequest, + h2: h2::legacy::client::SendRequest, } impl H2Client { - pub fn new(h2: h2::client::SendRequest) -> Self { + pub fn new(h2: h2::legacy::client::SendRequest) -> Self { Self { h2 } } @@ -1020,7 +1020,7 @@ impl H2Client { &self, request: Request<()>, data: Option, - ) -> impl Future> { + ) -> impl Future> { self.h2 .clone() .ready() @@ -1037,7 +1037,9 @@ impl H2Client { }) } - pub async fn h2api_response(response: Response) -> Result { + pub async fn h2api_response( + response: Response, + ) -> Result { let status = response.status(); let (_head, mut body) = response.into_parts(); diff --git a/pbs-client/src/pipe_to_stream.rs b/pbs-client/src/pipe_to_stream.rs index ae689851..3fc942d3 100644 --- a/pbs-client/src/pipe_to_stream.rs +++ b/pbs-client/src/pipe_to_stream.rs @@ -8,7 +8,7 @@ use std::task::{Context, Poll}; use anyhow::{format_err, Error}; use bytes::Bytes; use futures::{ready, Future}; -use h2::SendStream; +use h2::legacy::SendStream; pub struct PipeToSendStream { body_tx: SendStream,