From b0790a6066775e132cff62e29daf111cdf74d0a6 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 9 Mar 2023 15:06:50 -0800 Subject: [PATCH 1/2] client: add http2_timer option Currently, a timer must be provided to use http2. However, this has no option to actually configure this. This PR introduces a new function to set the timer. With this, I am able to successfully make HTTP2 calls with the Client. --- src/client/legacy.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/client/legacy.rs b/src/client/legacy.rs index 1d2dae8..c6bf73b 100644 --- a/src/client/legacy.rs +++ b/src/client/legacy.rs @@ -14,6 +14,7 @@ use std::time::Duration; use futures_util::future::{self, Either, FutureExt, TryFutureExt}; use http::uri::Scheme; use hyper::header::{HeaderValue, HOST}; +use hyper::rt::Timer; use hyper::{body::Body, Method, Request, Response, Uri, Version}; use tracing::{debug, trace, warn}; @@ -1349,6 +1350,22 @@ impl Builder { self } + /// Provide a timer to execute background HTTP2 tasks + /// + /// See the documentation of [`h2::client::Builder::timer`] for more + /// details. + /// + /// [`h2::client::Builder::timer`]: https://docs.rs/h2/client/struct.Builder.html#method.timer + pub fn timer(&mut self, timer: M) -> &mut Self + where + M: Timer + Send + Sync + 'static, + { + #[cfg(feature = "http2")] + self.h2_builder.timer(timer); + // TODO(https://github.com/hyperium/hyper/issues/3167) set for pool as well + self + } + /// Set the maximum write buffer size for each HTTP/2 stream. /// /// Default is currently 1MB, but may change. From 7b2c137ca2706365adc0ba2aaa47fc06b92b1bf5 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Wed, 15 Nov 2023 15:01:38 -0500 Subject: [PATCH 2/2] Update src/client/legacy.rs --- src/client/legacy.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/legacy.rs b/src/client/legacy.rs index c6bf73b..4b899b3 100644 --- a/src/client/legacy.rs +++ b/src/client/legacy.rs @@ -1350,7 +1350,7 @@ impl Builder { self } - /// Provide a timer to execute background HTTP2 tasks + /// Provide a timer to be used for timeouts and intervals. /// /// See the documentation of [`h2::client::Builder::timer`] for more /// details.