mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
update client error
This commit is contained in:
parent
c5c7b244be
commit
9037473e0f
@ -83,7 +83,7 @@ failure = { version = "0.1.5", optional = true }
|
||||
openssl = { version="0.10", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
actix-rt = "0.2.0"
|
||||
actix-rt = "0.2.1"
|
||||
actix-server = { version = "0.4.0", features=["ssl"] }
|
||||
actix-connect = { version = "0.1.0", features=["ssl"] }
|
||||
actix-http-test = { path="test-server", features=["ssl"] }
|
||||
|
10
src/body.rs
10
src/body.rs
@ -45,6 +45,16 @@ impl MessageBody for () {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: MessageBody> MessageBody for Box<T> {
|
||||
fn length(&self) -> BodyLength {
|
||||
self.as_ref().length()
|
||||
}
|
||||
|
||||
fn poll_next(&mut self) -> Poll<Option<Bytes>, Error> {
|
||||
self.as_mut().poll_next()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ResponseBody<B> {
|
||||
Body(B),
|
||||
Other(Body),
|
||||
|
@ -21,7 +21,7 @@ pub(crate) enum ConnectionType<Io> {
|
||||
pub trait Connection {
|
||||
type Future: Future<Item = ClientResponse, Error = SendRequestError>;
|
||||
|
||||
/// Close connection
|
||||
/// Send request and body
|
||||
fn send_request<B: MessageBody + 'static>(
|
||||
self,
|
||||
head: RequestHead,
|
||||
|
@ -7,6 +7,7 @@ use trust_dns_resolver::error::ResolveError;
|
||||
use openssl::ssl::{Error as SslError, HandshakeError};
|
||||
|
||||
use crate::error::{Error, ParseError, ResponseError};
|
||||
use crate::http::Error as HttpError;
|
||||
use crate::response::Response;
|
||||
|
||||
/// A set of errors that can occur while connecting to an HTTP host
|
||||
@ -98,6 +99,9 @@ pub enum SendRequestError {
|
||||
Send(io::Error),
|
||||
/// Error parsing response
|
||||
Response(ParseError),
|
||||
/// Http error
|
||||
#[display(fmt = "{}", _0)]
|
||||
Http(HttpError),
|
||||
/// Http2 error
|
||||
#[display(fmt = "{}", _0)]
|
||||
H2(h2::Error),
|
||||
|
@ -118,6 +118,11 @@ impl<B> ClientRequest<B>
|
||||
where
|
||||
B: MessageBody,
|
||||
{
|
||||
/// Create new client request
|
||||
pub fn new(head: RequestHead, body: B) -> Self {
|
||||
ClientRequest { head, body }
|
||||
}
|
||||
|
||||
/// Get the request URI
|
||||
#[inline]
|
||||
pub fn uri(&self) -> &Uri {
|
||||
@ -174,14 +179,14 @@ where
|
||||
// Send request
|
||||
///
|
||||
/// This method returns a future that resolves to a ClientResponse
|
||||
pub fn send<T, I>(
|
||||
pub fn send<T>(
|
||||
self,
|
||||
connector: &mut T,
|
||||
) -> impl Future<Item = ClientResponse, Error = SendRequestError>
|
||||
where
|
||||
B: 'static,
|
||||
T: Service<Request = Uri, Response = I, Error = ConnectError>,
|
||||
I: Connection,
|
||||
T: Service<Request = Uri, Error = ConnectError>,
|
||||
T::Response: Connection,
|
||||
{
|
||||
let Self { head, body } = self;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user