From b1a06f6a63a63410f89bd0d2968a6fdb7ce2352d Mon Sep 17 00:00:00 2001 From: Christoph Heiss Date: Thu, 5 Jun 2025 12:01:10 +0200 Subject: [PATCH 5/5] Revert "h2: switch to legacy feature" This reverts commit 168ed370263e84a6235968c615b856b9280debe1. It's a Proxmox-specific workaround (see also the commit description itself) and does not apply here. Signed-off-by: Christoph Heiss --- 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, 17 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 091696f1..063f62f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ env_logger = "0.11" flate2 = "1.0" foreign-types = "0.3" futures = "0.3" -h2 = { version = "0.4", features = [ "legacy", "stream" ] } +h2 = { version = "0.4", features = [ "stream" ] } handlebars = "3.0" hex = "0.4.3" hickory-resolver = { version = "0.24.1", default-features = false, features = [ "system-config", "tokio-runtime" ] } diff --git a/examples/h2client.rs b/examples/h2client.rs index e44c43fa..1dcb4498 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::legacy::RecvStream, + body: h2::RecvStream, trailers: bool, bytes: usize, } @@ -50,7 +50,7 @@ impl Future for Process { } fn send_request( - mut client: h2::legacy::client::SendRequest, + mut client: h2::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::legacy::client::Builder::new() + let (client, h2) = h2::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 86b3a931..a12b5a48 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::legacy::RecvStream, + body: h2::RecvStream, trailers: bool, bytes: usize, } @@ -50,7 +50,7 @@ impl Future for Process { } fn send_request( - mut client: h2::legacy::client::SendRequest, + mut client: h2::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::legacy::client::Builder::new() + let (client, h2) = h2::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 32542506..1253ef56 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::legacy::client::ResponseFuture, + future: h2::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::legacy::client::ResponseFuture| { + .try_for_each(move |response: h2::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 c95def07..8f6f8b41 100644 --- a/pbs-client/src/http_client.rs +++ b/pbs-client/src/http_client.rs @@ -863,7 +863,7 @@ impl HttpClient { let max_window_size = (1 << 31) - 2; - let (h2, connection) = h2::legacy::client::Builder::new() + let (h2, connection) = h2::client::Builder::new() .initial_connection_window_size(max_window_size) .initial_window_size(max_window_size) .max_frame_size(4 * 1024 * 1024) @@ -1008,11 +1008,11 @@ impl Drop for HttpClient { #[derive(Clone)] pub struct H2Client { - h2: h2::legacy::client::SendRequest, + h2: h2::client::SendRequest, } impl H2Client { - pub fn new(h2: h2::legacy::client::SendRequest) -> Self { + pub fn new(h2: h2::client::SendRequest) -> Self { Self { h2 } } @@ -1092,7 +1092,7 @@ impl H2Client { &self, request: Request<()>, data: Option, - ) -> impl Future> { + ) -> impl Future> { self.h2 .clone() .ready() @@ -1109,9 +1109,7 @@ 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 3fc942d3..ae689851 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::legacy::SendStream; +use h2::SendStream; pub struct PipeToSendStream { body_tx: SendStream, -- 2.49.0