mirror of
https://github.com/actix/actix-web.git
synced 2024-11-26 11:31:09 +00:00
Use more ergonomic actix_web::Error instead of http::Error for ClientRequestBuilder::body()
This commit is contained in:
parent
e49910cdab
commit
93d99b5a49
3 changed files with 12 additions and 10 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
* Use more ergonomic `actix_web::Error` instead of `http::Error` for `HttpResponseBuilder::body()`
|
||||
|
||||
* Use more ergonomic `actix_web::Error` instead of `http::Error` for `ClientRequestBuilder::body()`
|
||||
|
||||
|
||||
## 0.4.10 (2018-03-20)
|
||||
|
||||
|
|
|
@ -542,9 +542,9 @@ impl ClientRequestBuilder {
|
|||
/// Set a body and generate `ClientRequest`.
|
||||
///
|
||||
/// `ClientRequestBuilder` can not be used after this call.
|
||||
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<ClientRequest, HttpError> {
|
||||
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<ClientRequest, Error> {
|
||||
if let Some(e) = self.err.take() {
|
||||
return Err(e)
|
||||
return Err(e.into())
|
||||
}
|
||||
|
||||
if self.default_headers {
|
||||
|
@ -596,13 +596,13 @@ impl ClientRequestBuilder {
|
|||
self.header(header::CONTENT_TYPE, "application/json");
|
||||
}
|
||||
|
||||
Ok(self.body(body)?)
|
||||
self.body(body)
|
||||
}
|
||||
|
||||
/// Set a streaming body and generate `ClientRequest`.
|
||||
///
|
||||
/// `ClientRequestBuilder` can not be used after this call.
|
||||
pub fn streaming<S, E>(&mut self, stream: S) -> Result<ClientRequest, HttpError>
|
||||
pub fn streaming<S, E>(&mut self, stream: S) -> Result<ClientRequest, Error>
|
||||
where S: Stream<Item=Bytes, Error=E> + 'static,
|
||||
E: Into<Error>,
|
||||
{
|
||||
|
@ -612,7 +612,7 @@ impl ClientRequestBuilder {
|
|||
/// Set an empty body and generate `ClientRequest`
|
||||
///
|
||||
/// `ClientRequestBuilder` can not be used after this call.
|
||||
pub fn finish(&mut self) -> Result<ClientRequest, HttpError> {
|
||||
pub fn finish(&mut self) -> Result<ClientRequest, Error> {
|
||||
self.body(Body::Empty)
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ use futures::unsync::mpsc::{unbounded, UnboundedSender};
|
|||
use actix::prelude::*;
|
||||
|
||||
use body::{Body, Binary};
|
||||
use error::UrlParseError;
|
||||
use error::{Error, UrlParseError};
|
||||
use header::IntoHeaderValue;
|
||||
use payload::PayloadHelper;
|
||||
use httpmessage::HttpMessage;
|
||||
|
@ -68,7 +68,7 @@ pub enum ClientError {
|
|||
#[fail(display="Invalid challenge response")]
|
||||
InvalidChallengeResponse(String, HeaderValue),
|
||||
#[fail(display="Http parsing error")]
|
||||
Http(HttpError),
|
||||
Http(Error),
|
||||
#[fail(display="Url parsing error")]
|
||||
Url(UrlParseError),
|
||||
#[fail(display="Response parsing error")]
|
||||
|
@ -83,8 +83,8 @@ pub enum ClientError {
|
|||
Disconnected,
|
||||
}
|
||||
|
||||
impl From<HttpError> for ClientError {
|
||||
fn from(err: HttpError) -> ClientError {
|
||||
impl From<Error> for ClientError {
|
||||
fn from(err: Error) -> ClientError {
|
||||
ClientError::Http(err)
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ impl Client {
|
|||
ClientHandshake::error(e)
|
||||
}
|
||||
else if let Some(e) = self.http_err.take() {
|
||||
ClientHandshake::error(e.into())
|
||||
ClientHandshake::error(Error::from(e).into())
|
||||
} else {
|
||||
// origin
|
||||
if let Some(origin) = self.origin.take() {
|
||||
|
|
Loading…
Reference in a new issue