Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

add simple_http_with_timeout #109

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
17 changes: 17 additions & 0 deletions src/simple_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,23 @@ impl crate::Client {
Ok(crate::Client::with_transport(builder.build()))
}

/// Creates a new JSON-RPC client using a bare-minimum HTTP transport.
pub fn simple_http_with_timeout(
url: &str,
user: Option<String>,
pass: Option<String>,
timeout: Option<Duration>,
) -> Result<crate::Client, Error> {
let mut builder = Builder::new().url(url)?;
if let Some(user) = user {
builder = builder.auth(user, pass);
}
if let Some(timeout) = timeout {
builder = builder.timeout(timeout);
}
Ok(crate::Client::with_transport(builder.build()))
}

#[cfg(feature = "proxy")]
/// Creates a new JSON_RPC client using a HTTP-Socks5 proxy transport.
pub fn http_proxy(
Expand Down