mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
cleanup imports
This commit is contained in:
parent
b81417c2fa
commit
c1deaaeb2f
@ -1,6 +1,6 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
## [1.0.0] - 2019-12-xx
|
## [1.0.0] - 2019-12-13
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
@ -56,7 +56,9 @@ chrono = "0.4.6"
|
|||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
either = "1.5.3"
|
either = "1.5.3"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures = "0.3.1"
|
futures-core = "0.3.1"
|
||||||
|
futures-util = "0.3.1"
|
||||||
|
futures-channel = "0.3.1"
|
||||||
fxhash = "0.2.1"
|
fxhash = "0.2.1"
|
||||||
h2 = "0.2.1"
|
h2 = "0.2.1"
|
||||||
http = "0.2.0"
|
http = "0.2.0"
|
||||||
@ -92,6 +94,7 @@ actix-server = "1.0.0"
|
|||||||
actix-connect = { version = "1.0.0", features=["openssl"] }
|
actix-connect = { version = "1.0.0", features=["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
||||||
actix-tls = { version = "1.0.0", features=["openssl"] }
|
actix-tls = { version = "1.0.0", features=["openssl"] }
|
||||||
|
futures = "0.3.1"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
open-ssl = { version="0.10", package = "openssl" }
|
open-ssl = { version="0.10", package = "openssl" }
|
||||||
|
@ -4,7 +4,7 @@ use std::task::{Context, Poll};
|
|||||||
use std::{fmt, mem};
|
use std::{fmt, mem};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
use pin_project::{pin_project, project};
|
use pin_project::{pin_project, project};
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
@ -435,7 +435,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use futures::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
|
|
||||||
impl Body {
|
impl Body {
|
||||||
pub(crate) fn get_ref(&self) -> &[u8] {
|
pub(crate) fn get_ref(&self) -> &[u8] {
|
||||||
|
@ -4,7 +4,7 @@ use std::{fmt, io, mem, time};
|
|||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
||||||
use bytes::{Buf, Bytes};
|
use bytes::{Buf, Bytes};
|
||||||
use futures::future::{err, Either, Future, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{err, Either, Future, FutureExt, LocalBoxFuture, Ready};
|
||||||
use h2::client::SendRequest;
|
use h2::client::SendRequest;
|
||||||
use pin_project::{pin_project, project};
|
use pin_project::{pin_project, project};
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ where
|
|||||||
mod connect_impl {
|
mod connect_impl {
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use futures::future::{err, Either, Ready};
|
use futures_util::future::{err, Either, Ready};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::client::connection::IoConnection;
|
use crate::client::connection::IoConnection;
|
||||||
@ -400,8 +400,8 @@ mod connect_impl {
|
|||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use futures::future::Either;
|
use futures_core::ready;
|
||||||
use futures::ready;
|
use futures_util::future::Either;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::client::connection::EitherConnection;
|
use crate::client::connection::EitherConnection;
|
||||||
|
@ -6,8 +6,9 @@ use std::{io, mem, time};
|
|||||||
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
||||||
use bytes::buf::BufMutExt;
|
use bytes::buf::BufMutExt;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::poll_fn;
|
use futures_core::Stream;
|
||||||
use futures::{SinkExt, Stream, StreamExt};
|
use futures_util::future::poll_fn;
|
||||||
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
use crate::error::PayloadError;
|
use crate::error::PayloadError;
|
||||||
use crate::h1;
|
use crate::h1;
|
||||||
|
@ -3,7 +3,7 @@ use std::time;
|
|||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite};
|
use actix_codec::{AsyncRead, AsyncWrite};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
use h2::{client::SendRequest, SendStream};
|
use h2::{client::SendRequest, SendStream};
|
||||||
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
|
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
|
||||||
use http::{request::Request, Method, Version};
|
use http::{request::Request, Method, Version};
|
||||||
|
@ -11,7 +11,7 @@ use actix_rt::time::{delay_for, Delay};
|
|||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use actix_utils::{oneshot, task::LocalWaker};
|
use actix_utils::{oneshot, task::LocalWaker};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{poll_fn, FutureExt, LocalBoxFuture};
|
use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture};
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
use h2::client::{handshake, Connection, SendRequest};
|
use h2::client::{handshake, Connection, SendRequest};
|
||||||
use http::uri::Authority;
|
use http::uri::Authority;
|
||||||
|
@ -6,7 +6,7 @@ use std::{fmt, net};
|
|||||||
|
|
||||||
use actix_rt::time::{delay_for, delay_until, Delay, Instant};
|
use actix_rt::time::{delay_for, delay_until, Delay, Instant};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::{future, FutureExt};
|
use futures_util::{future, FutureExt};
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
// "Sun, 06 Nov 1994 08:49:37 GMT".len()
|
// "Sun, 06 Nov 1994 08:49:37 GMT".len()
|
||||||
|
@ -7,7 +7,7 @@ use actix_threadpool::{run, CpuFuture};
|
|||||||
use brotli::DecompressorWriter;
|
use brotli::DecompressorWriter;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flate2::write::{GzDecoder, ZlibDecoder};
|
use flate2::write::{GzDecoder, ZlibDecoder};
|
||||||
use futures::{ready, Stream};
|
use futures_core::{ready, Stream};
|
||||||
|
|
||||||
use super::Writer;
|
use super::Writer;
|
||||||
use crate::error::PayloadError;
|
use crate::error::PayloadError;
|
||||||
|
@ -8,6 +8,7 @@ use actix_threadpool::{run, CpuFuture};
|
|||||||
use brotli::CompressorWriter;
|
use brotli::CompressorWriter;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use flate2::write::{GzEncoder, ZlibEncoder};
|
use flate2::write::{GzEncoder, ZlibEncoder};
|
||||||
|
use futures_core::ready;
|
||||||
|
|
||||||
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
|
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
|
||||||
use crate::http::header::{ContentEncoding, CONTENT_ENCODING};
|
use crate::http::header::{ContentEncoding, CONTENT_ENCODING};
|
||||||
@ -101,7 +102,7 @@ impl<B: MessageBody> MessageBody for Encoder<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut fut) = self.fut {
|
if let Some(ref mut fut) = self.fut {
|
||||||
let mut encoder = match futures::ready!(Pin::new(fut).poll(cx)) {
|
let mut encoder = match ready!(Pin::new(fut).poll(cx)) {
|
||||||
Ok(item) => item,
|
Ok(item) => item,
|
||||||
Err(e) => return Poll::Ready(Some(Err(e.into()))),
|
Err(e) => return Poll::Ready(Some(Err(e.into()))),
|
||||||
};
|
};
|
||||||
|
@ -10,7 +10,7 @@ pub use actix_threadpool::BlockingError;
|
|||||||
use actix_utils::timeout::TimeoutError;
|
use actix_utils::timeout::TimeoutError;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use derive_more::{Display, From};
|
use derive_more::{Display, From};
|
||||||
pub use futures::channel::oneshot::Canceled;
|
pub use futures_channel::oneshot::Canceled;
|
||||||
use http::uri::InvalidUri;
|
use http::uri::InvalidUri;
|
||||||
use http::{header, Error as HttpError, StatusCode};
|
use http::{header, Error as HttpError, StatusCode};
|
||||||
use httparse;
|
use httparse;
|
||||||
|
@ -195,17 +195,11 @@ impl Encoder for Codec {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{cmp, io};
|
use bytes::BytesMut;
|
||||||
|
use http::Method;
|
||||||
use actix_codec::{AsyncRead, AsyncWrite};
|
|
||||||
use bytes::{Buf, Bytes, BytesMut};
|
|
||||||
use http::{Method, Version};
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::error::ParseError;
|
|
||||||
use crate::h1::Message;
|
|
||||||
use crate::httpmessage::HttpMessage;
|
use crate::httpmessage::HttpMessage;
|
||||||
use crate::request::Request;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_http_request_chunked_payload_and_next_message() {
|
fn test_http_request_chunked_payload_and_next_message() {
|
||||||
|
@ -912,7 +912,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::IntoService;
|
use actix_service::IntoService;
|
||||||
use futures::future::{lazy, ok};
|
use futures_util::future::{lazy, ok};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
|
@ -521,12 +521,14 @@ fn write_camel_case(value: &[u8], buffer: &mut [u8]) {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::rc::Rc;
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
//use std::rc::Rc;
|
use http::header::AUTHORIZATION;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::http::header::{HeaderValue, CONTENT_TYPE};
|
use crate::http::header::{HeaderValue, CONTENT_TYPE};
|
||||||
use http::header::AUTHORIZATION;
|
use crate::RequestHead;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_chunked_te() {
|
fn test_chunked_te() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
|
@ -7,7 +7,7 @@ use std::task::{Context, Poll};
|
|||||||
|
|
||||||
use actix_utils::task::LocalWaker;
|
use actix_utils::task::LocalWaker;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
|
|
||||||
use crate::error::PayloadError;
|
use crate::error::PayloadError;
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ impl Inner {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use futures::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_unread_data() {
|
async fn test_unread_data() {
|
||||||
|
@ -8,8 +8,8 @@ use std::{fmt, net};
|
|||||||
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
||||||
use futures::future::{ok, Ready};
|
use futures_core::ready;
|
||||||
use futures::ready;
|
use futures_util::future::{ok, Ready};
|
||||||
|
|
||||||
use crate::body::MessageBody;
|
use crate::body::MessageBody;
|
||||||
use crate::cloneable::CloneableService;
|
use crate::cloneable::CloneableService;
|
||||||
|
@ -3,7 +3,7 @@ use std::task::{Context, Poll};
|
|||||||
|
|
||||||
use actix_codec::Framed;
|
use actix_codec::Framed;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::Ready;
|
use futures_util::future::Ready;
|
||||||
|
|
||||||
use crate::error::Error;
|
use crate::error::Error;
|
||||||
use crate::h1::Codec;
|
use crate::h1::Codec;
|
||||||
|
@ -3,7 +3,7 @@ use std::pin::Pin;
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
use h2::RecvStream;
|
use h2::RecvStream;
|
||||||
|
|
||||||
mod dispatcher;
|
mod dispatcher;
|
||||||
|
@ -11,8 +11,8 @@ use actix_service::{
|
|||||||
ServiceFactory,
|
ServiceFactory,
|
||||||
};
|
};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::ok;
|
use futures_core::ready;
|
||||||
use futures::ready;
|
use futures_util::future::ok;
|
||||||
use h2::server::{self, Handshake};
|
use h2::server::{self, Handshake};
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
@ -141,9 +141,9 @@ mod openssl {
|
|||||||
#[cfg(feature = "rustls")]
|
#[cfg(feature = "rustls")]
|
||||||
mod rustls {
|
mod rustls {
|
||||||
use super::*;
|
use super::*;
|
||||||
use actix_tls::rustls::{Acceptor, ServerConfig, Session, TlsStream};
|
use actix_tls::rustls::{Acceptor, ServerConfig, TlsStream};
|
||||||
use actix_tls::SslError;
|
use actix_tls::SslError;
|
||||||
use std::{fmt, io};
|
use std::io;
|
||||||
|
|
||||||
impl<S, B> H2Service<TlsStream<TcpStream>, S, B>
|
impl<S, B> H2Service<TlsStream<TcpStream>, S, B>
|
||||||
where
|
where
|
||||||
|
@ -2,7 +2,7 @@ use std::pin::Pin;
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
use h2::RecvStream;
|
use h2::RecvStream;
|
||||||
|
|
||||||
use crate::error::PayloadError;
|
use crate::error::PayloadError;
|
||||||
|
@ -7,7 +7,7 @@ use std::task::{Context, Poll};
|
|||||||
use std::{fmt, str};
|
use std::{fmt, str};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::stream::Stream;
|
use futures_core::Stream;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
|||||||
use actix_rt::net::TcpStream;
|
use actix_rt::net::TcpStream;
|
||||||
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::{future::ok, ready, Future};
|
use futures_core::{ready, Future};
|
||||||
|
use futures_util::future::ok;
|
||||||
use h2::server::{self, Handshake};
|
use h2::server::{self, Handshake};
|
||||||
use pin_project::{pin_project, project};
|
use pin_project::{pin_project, project};
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [1.0.0] - 2019-12-13
|
||||||
|
|
||||||
|
* Release
|
||||||
|
|
||||||
## [1.0.0-alpha.3]
|
## [1.0.0-alpha.3]
|
||||||
|
|
||||||
* Migrate to `std::future`
|
* Migrate to `std::future`
|
||||||
|
@ -42,7 +42,7 @@ actix-rt = "1.0.0"
|
|||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures = "0.3.1"
|
futures-core = "0.3.1"
|
||||||
log =" 0.4"
|
log =" 0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
@ -63,5 +63,6 @@ actix-server = "1.0.0"
|
|||||||
actix-tls = { version = "1.0.0", features=["openssl", "rustls"] }
|
actix-tls = { version = "1.0.0", features=["openssl", "rustls"] }
|
||||||
brotli = "3.3.0"
|
brotli = "3.3.0"
|
||||||
flate2 = "1.0.13"
|
flate2 = "1.0.13"
|
||||||
|
futures = "0.3.1"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
webpki = "0.21"
|
webpki = "0.21"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
@ -12,7 +13,6 @@ use actix_http::h1::ClientCodec;
|
|||||||
use actix_http::http::HeaderMap;
|
use actix_http::http::HeaderMap;
|
||||||
use actix_http::{RequestHead, RequestHeadType, ResponseHead};
|
use actix_http::{RequestHead, RequestHeadType, ResponseHead};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use futures::future::{FutureExt, LocalBoxFuture};
|
|
||||||
|
|
||||||
use crate::response::ClientResponse;
|
use crate::response::ClientResponse;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ pub(crate) trait Connect {
|
|||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>;
|
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>;
|
||||||
|
|
||||||
fn send_request_extra(
|
fn send_request_extra(
|
||||||
&mut self,
|
&mut self,
|
||||||
@ -32,16 +32,22 @@ pub(crate) trait Connect {
|
|||||||
extra_headers: Option<HeaderMap>,
|
extra_headers: Option<HeaderMap>,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>;
|
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>;
|
||||||
|
|
||||||
/// Send request, returns Response and Framed
|
/// Send request, returns Response and Framed
|
||||||
fn open_tunnel(
|
fn open_tunnel(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<
|
) -> Pin<
|
||||||
'static,
|
Box<
|
||||||
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
|
dyn Future<
|
||||||
|
Output = Result<
|
||||||
|
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
||||||
|
SendRequestError,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/// Send request and extra headers, returns Response and Framed
|
/// Send request and extra headers, returns Response and Framed
|
||||||
@ -50,9 +56,15 @@ pub(crate) trait Connect {
|
|||||||
head: Rc<RequestHead>,
|
head: Rc<RequestHead>,
|
||||||
extra_headers: Option<HeaderMap>,
|
extra_headers: Option<HeaderMap>,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<
|
) -> Pin<
|
||||||
'static,
|
Box<
|
||||||
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
|
dyn Future<
|
||||||
|
Output = Result<
|
||||||
|
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
||||||
|
SendRequestError,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
>;
|
>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,14 +82,14 @@ where
|
|||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>> {
|
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>> {
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
uri: head.uri.clone(),
|
uri: head.uri.clone(),
|
||||||
addr,
|
addr,
|
||||||
});
|
});
|
||||||
|
|
||||||
async move {
|
Box::pin(async move {
|
||||||
let connection = fut.await?;
|
let connection = fut.await?;
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
@ -85,8 +97,7 @@ where
|
|||||||
.send_request(RequestHeadType::from(head), body)
|
.send_request(RequestHeadType::from(head), body)
|
||||||
.await
|
.await
|
||||||
.map(|(head, payload)| ClientResponse::new(head, payload))
|
.map(|(head, payload)| ClientResponse::new(head, payload))
|
||||||
}
|
})
|
||||||
.boxed_local()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_request_extra(
|
fn send_request_extra(
|
||||||
@ -95,14 +106,14 @@ where
|
|||||||
extra_headers: Option<HeaderMap>,
|
extra_headers: Option<HeaderMap>,
|
||||||
body: Body,
|
body: Body,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>> {
|
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>> {
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
uri: head.uri.clone(),
|
uri: head.uri.clone(),
|
||||||
addr,
|
addr,
|
||||||
});
|
});
|
||||||
|
|
||||||
async move {
|
Box::pin(async move {
|
||||||
let connection = fut.await?;
|
let connection = fut.await?;
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
@ -111,17 +122,22 @@ where
|
|||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
Ok(ClientResponse::new(head, payload))
|
Ok(ClientResponse::new(head, payload))
|
||||||
}
|
})
|
||||||
.boxed_local()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_tunnel(
|
fn open_tunnel(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: RequestHead,
|
head: RequestHead,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<
|
) -> Pin<
|
||||||
'static,
|
Box<
|
||||||
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
|
dyn Future<
|
||||||
|
Output = Result<
|
||||||
|
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
||||||
|
SendRequestError,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
> {
|
> {
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
@ -129,7 +145,7 @@ where
|
|||||||
addr,
|
addr,
|
||||||
});
|
});
|
||||||
|
|
||||||
async move {
|
Box::pin(async move {
|
||||||
let connection = fut.await?;
|
let connection = fut.await?;
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
@ -138,8 +154,7 @@ where
|
|||||||
|
|
||||||
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
|
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
|
||||||
Ok((head, framed))
|
Ok((head, framed))
|
||||||
}
|
})
|
||||||
.boxed_local()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_tunnel_extra(
|
fn open_tunnel_extra(
|
||||||
@ -147,9 +162,15 @@ where
|
|||||||
head: Rc<RequestHead>,
|
head: Rc<RequestHead>,
|
||||||
extra_headers: Option<HeaderMap>,
|
extra_headers: Option<HeaderMap>,
|
||||||
addr: Option<net::SocketAddr>,
|
addr: Option<net::SocketAddr>,
|
||||||
) -> LocalBoxFuture<
|
) -> Pin<
|
||||||
'static,
|
Box<
|
||||||
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
|
dyn Future<
|
||||||
|
Output = Result<
|
||||||
|
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
|
||||||
|
SendRequestError,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
|
>,
|
||||||
> {
|
> {
|
||||||
// connect to the host
|
// connect to the host
|
||||||
let fut = self.0.call(ClientConnect {
|
let fut = self.0.call(ClientConnect {
|
||||||
@ -157,7 +178,7 @@ where
|
|||||||
addr,
|
addr,
|
||||||
});
|
});
|
||||||
|
|
||||||
async move {
|
Box::pin(async move {
|
||||||
let connection = fut.await?;
|
let connection = fut.await?;
|
||||||
|
|
||||||
// send request
|
// send request
|
||||||
@ -167,8 +188,7 @@ where
|
|||||||
|
|
||||||
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
|
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
|
||||||
Ok((head, framed))
|
Ok((head, framed))
|
||||||
}
|
})
|
||||||
.boxed_local()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use actix_http::body::Body;
|
use actix_http::body::Body;
|
||||||
|
@ -5,7 +5,7 @@ use std::time::Duration;
|
|||||||
use std::{fmt, net};
|
use std::{fmt, net};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::Stream;
|
||||||
use percent_encoding::percent_encode;
|
use percent_encoding::percent_encode;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use std::pin::Pin;
|
|||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::{ready, Future, Stream};
|
use futures_core::{ready, Future, Stream};
|
||||||
|
|
||||||
use actix_http::cookie::Cookie;
|
use actix_http::cookie::Cookie;
|
||||||
use actix_http::error::{CookieParseError, PayloadError};
|
use actix_http::error::{CookieParseError, PayloadError};
|
||||||
|
@ -7,7 +7,7 @@ use std::time::Duration;
|
|||||||
use actix_rt::time::{delay_for, Delay};
|
use actix_rt::time::{delay_for, Delay};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use derive_more::From;
|
use derive_more::From;
|
||||||
use futures::{future::LocalBoxFuture, ready, Future, Stream};
|
use futures_core::{ready, Future, Stream};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
@ -49,7 +49,7 @@ impl Into<SendRequestError> for PrepForSendingError {
|
|||||||
#[must_use = "futures do nothing unless polled"]
|
#[must_use = "futures do nothing unless polled"]
|
||||||
pub enum SendClientRequest {
|
pub enum SendClientRequest {
|
||||||
Fut(
|
Fut(
|
||||||
LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>,
|
Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>,
|
||||||
Option<Delay>,
|
Option<Delay>,
|
||||||
bool,
|
bool,
|
||||||
),
|
),
|
||||||
@ -58,7 +58,7 @@ pub enum SendClientRequest {
|
|||||||
|
|
||||||
impl SendClientRequest {
|
impl SendClientRequest {
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
send: LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>,
|
send: Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>,
|
||||||
response_decompress: bool,
|
response_decompress: bool,
|
||||||
timeout: Option<Duration>,
|
timeout: Option<Duration>,
|
||||||
) -> SendClientRequest {
|
) -> SendClientRequest {
|
||||||
|
Loading…
Reference in New Issue
Block a user