Skip to content

Commit

Permalink
client: add http2_timer option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
howardjohn committed Mar 9, 2023
1 parent 3c37c5b commit 980215e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/client/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -1347,6 +1348,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
#[cfg(feature = "http2")]
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
pub fn http2_timer<M>(&mut self, timer: M) -> &mut Self
where
M: Timer + Send + Sync + 'static,
{
self.h2_builder.timer(timer);
self
}

/// Set the maximum write buffer size for each HTTP/2 stream.
///
/// Default is currently 1MB, but may change.
Expand Down

0 comments on commit 980215e

Please sign in to comment.