1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 02:19:22 +02:00

Use more ergonomic actix_web::Error instead of http::Error for ClientRequestBuilder::body()

This commit is contained in:
Nikolay Kim
2018-03-21 20:19:31 -07:00
parent e49910cdab
commit 93d99b5a49
3 changed files with 12 additions and 10 deletions

View File

@ -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)
}