diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index 9366a2c3d087..ea3a7f8ba2b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -73,6 +73,7 @@ use std::collections::HashMap; use std::io::Write; use std::path::Path; use std::string::{FromUtf8Error, ToString}; +use std::time::Duration; #[cfg(feature = "json")] use serde::Serialize; #[cfg(feature = "json")] use serde::de::DeserializeOwned; @@ -220,6 +221,13 @@ impl <'a> Request<'a> { Ok(self) } + /// Configure a timeout for the request after which the request + /// will be aborted. + pub fn timeout(mut self, timeout: Duration) -> Result<Self, curl::Error> { + self.handle.timeout(timeout)?; + Ok(self) + } + /// Add a byte-array body to a request using the specified /// `Content-Type`. pub fn body(mut self, content_type: &'a str, data: &'a [u8]) -> Self { |