feat: Add Request::timeout
method
This commit is contained in:
parent
acc7e64a0d
commit
df117f855b
1 changed files with 8 additions and 0 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue