Skip to content

Commit

Permalink
client: add timer() option (#25)
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 authored Nov 15, 2023
1 parent 4069dda commit 0c187a3
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 @@ -1349,6 +1350,22 @@ impl Builder {
self
}

/// Provide a timer to be used for timeouts and intervals.
///
/// 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<M>(&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.
Expand Down

0 comments on commit 0c187a3

Please sign in to comment.