feat: Add Request::timeout method

This commit is contained in:
Vincent Ambo 2019-02-26 17:54:47 +01:00
parent acc7e64a0d
commit df117f855b

View file

@ -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 {