Make the blocking API an optional feature (default off)

This commit is contained in:
Sean McArthur
2019-09-17 15:06:10 -07:00
parent 0a87d3d7da
commit 7e3c1bc461
11 changed files with 71 additions and 49 deletions

View File

@@ -3,7 +3,11 @@
//! The blocking `Client` will block the current thread to execute, instead
//! of returning futures that need to be executed on a runtime.
//!
//! ## Making a GET request
//! # Optional
//!
//! This requires the optional `blocking` feature to be enabled.
//!
//! # Making a GET request
//!
//! For a single request, you can use the [`get`](get) shortcut method.
//!
@@ -28,7 +32,7 @@
//! [`Client`](Client) and reuse it, taking advantage of keep-alive connection
//! pooling.
//!
//! ## Making POST requests (or setting request bodies)
//! # Making POST requests (or setting request bodies)
//!
//! There are several ways you can set the body of a request. The basic one is
//! by using the `body()` method of a [`RequestBuilder`](RequestBuilder). This lets you set the

View File

@@ -290,7 +290,7 @@ impl Response {
where
W: io::Write,
{
io::copy(self, w).map_err(crate::error::response)
io::copy(self, w).map_err(crate::error::decode_io)
}
/// Turn a response into an error if the server returned an error.
@@ -365,8 +365,8 @@ impl Read for Response {
let timeout = self.timeout;
wait::timeout(self.body_mut().read(buf), timeout).map_err(|e| match e {
wait::Waited::TimedOut(e) => crate::error::response(e).into_io(),
wait::Waited::Executor(e) => crate::error::response(e).into_io(),
wait::Waited::TimedOut(e) => crate::error::decode(e).into_io(),
wait::Waited::Executor(e) => crate::error::decode(e).into_io(),
wait::Waited::Inner(e) => e,
})
}