Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Arguments:

Options:
-n <N_REQUESTS>
Number of requests to run. [default: 200]
Number of requests to run. Accepts plain numbers or suffixes: k = 1,000, m = 1,000,000 (e.g. 10k, 1m). [default: 200]
-c <N_CONNECTIONS>
Number of connections to run concurrently. You may should increase limit to number of open files for larger `-c`. [default: 50]
-p <N_HTTP2_PARALLEL>
Expand Down Expand Up @@ -148,6 +148,8 @@ Options:
Custom Proxy HTTP header. Examples: --proxy-header "foo: bar"
-t <TIMEOUT>
Timeout for each request. Default to infinite.
--connect-timeout <CONNECT_TIMEOUT>
Timeout for establishing a new connection. Default to 5s.
-A <ACCEPT_HEADER>
HTTP Accept Header.
-d <BODY_STRING>
Expand Down
5 changes: 3 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ pub struct Client {
pub proxy_headers: http::header::HeaderMap,
pub dns: Dns,
pub timeout: Option<std::time::Duration>,
pub connect_timeout: std::time::Duration,
pub redirect_limit: usize,
pub disable_keepalive: bool,
pub proxy_url: Option<Url>,
Expand Down Expand Up @@ -234,6 +235,7 @@ impl Default for Client {
connect_to: Vec::new(),
},
timeout: None,
connect_timeout: std::time::Duration::from_secs(5),
redirect_limit: 0,
disable_keepalive: false,
proxy_url: None,
Expand Down Expand Up @@ -452,8 +454,7 @@ impl Client {
rng: &mut R,
http_version: http::Version,
) -> Result<(Instant, Stream), ClientError> {
// TODO: Allow the connect timeout to be configured
let timeout_duration = tokio::time::Duration::from_secs(5);
let timeout_duration = self.connect_timeout;

#[cfg(feature = "http3")]
if http_version == http::Version::HTTP_3 {
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ Note: If qps is specified, burst will be ignored",
proxy_headers: Vec<String>,
#[arg(help = "Timeout for each request. Default to infinite.", short = 't')]
timeout: Option<humantime::Duration>,
#[arg(
help = "Timeout for establishing a new connection. Default to 5s.",
long = "connect-timeout",
default_value = "5s"
)]
connect_timeout: humantime::Duration,
#[arg(help = "HTTP Accept Header.", short = 'A')]
accept_header: Option<String>,
#[arg(help = "HTTP request body.", short = 'd', conflicts_with_all = ["body_path", "body_path_lines", "form"])]
Expand Down Expand Up @@ -655,6 +661,7 @@ pub async fn run(mut opts: Opts) -> anyhow::Result<()> {
connect_to: opts.connect_to,
},
timeout: opts.timeout.map(|d| d.into()),
connect_timeout: opts.connect_timeout.into(),
redirect_limit: opts.redirect,
disable_keepalive: opts.disable_keepalive,
proxy_url: opts.proxy,
Expand Down