1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-20 15:17:07 +00:00

cleanup imports

This commit is contained in:
Nikolay Kim 2019-12-13 11:24:57 +06:00
parent b81417c2fa
commit c1deaaeb2f
31 changed files with 104 additions and 77 deletions

View file

@ -1,6 +1,6 @@
# Changes
## [1.0.0] - 2019-12-xx
## [1.0.0] - 2019-12-13
### Added

View file

@ -56,7 +56,9 @@ chrono = "0.4.6"
derive_more = "0.99.2"
either = "1.5.3"
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"
h2 = "0.2.1"
http = "0.2.0"
@ -92,6 +94,7 @@ actix-server = "1.0.0"
actix-connect = { version = "1.0.0", features=["openssl"] }
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
actix-tls = { version = "1.0.0", features=["openssl"] }
futures = "0.3.1"
env_logger = "0.6"
serde_derive = "1.0"
open-ssl = { version="0.10", package = "openssl" }

View file

@ -4,7 +4,7 @@ use std::task::{Context, Poll};
use std::{fmt, mem};
use bytes::{Bytes, BytesMut};
use futures::Stream;
use futures_core::Stream;
use pin_project::{pin_project, project};
use crate::error::Error;
@ -435,7 +435,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use futures::future::poll_fn;
use futures_util::future::poll_fn;
impl Body {
pub(crate) fn get_ref(&self) -> &[u8] {

View file

@ -4,7 +4,7 @@ use std::{fmt, io, mem, time};
use actix_codec::{AsyncRead, AsyncWrite, Framed};
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 pin_project::{pin_project, project};

View file

@ -337,7 +337,7 @@ where
mod connect_impl {
use std::task::{Context, Poll};
use futures::future::{err, Either, Ready};
use futures_util::future::{err, Either, Ready};
use super::*;
use crate::client::connection::IoConnection;
@ -400,8 +400,8 @@ mod connect_impl {
use std::pin::Pin;
use std::task::{Context, Poll};
use futures::future::Either;
use futures::ready;
use futures_core::ready;
use futures_util::future::Either;
use super::*;
use crate::client::connection::EitherConnection;

View file

@ -6,8 +6,9 @@ use std::{io, mem, time};
use actix_codec::{AsyncRead, AsyncWrite, Framed};
use bytes::buf::BufMutExt;
use bytes::{Bytes, BytesMut};
use futures::future::poll_fn;
use futures::{SinkExt, Stream, StreamExt};
use futures_core::Stream;
use futures_util::future::poll_fn;
use futures_util::{SinkExt, StreamExt};
use crate::error::PayloadError;
use crate::h1;

View file

@ -3,7 +3,7 @@ use std::time;
use actix_codec::{AsyncRead, AsyncWrite};
use bytes::Bytes;
use futures::future::poll_fn;
use futures_util::future::poll_fn;
use h2::{client::SendRequest, SendStream};
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
use http::{request::Request, Method, Version};

View file

@ -11,7 +11,7 @@ use actix_rt::time::{delay_for, Delay};
use actix_service::Service;
use actix_utils::{oneshot, task::LocalWaker};
use bytes::Bytes;
use futures::future::{poll_fn, FutureExt, LocalBoxFuture};
use futures_util::future::{poll_fn, FutureExt, LocalBoxFuture};
use fxhash::FxHashMap;
use h2::client::{handshake, Connection, SendRequest};
use http::uri::Authority;

View file

@ -6,7 +6,7 @@ use std::{fmt, net};
use actix_rt::time::{delay_for, delay_until, Delay, Instant};
use bytes::BytesMut;
use futures::{future, FutureExt};
use futures_util::{future, FutureExt};
use time;
// "Sun, 06 Nov 1994 08:49:37 GMT".len()

View file

@ -7,7 +7,7 @@ use actix_threadpool::{run, CpuFuture};
use brotli::DecompressorWriter;
use bytes::Bytes;
use flate2::write::{GzDecoder, ZlibDecoder};
use futures::{ready, Stream};
use futures_core::{ready, Stream};
use super::Writer;
use crate::error::PayloadError;

View file

@ -8,6 +8,7 @@ use actix_threadpool::{run, CpuFuture};
use brotli::CompressorWriter;
use bytes::Bytes;
use flate2::write::{GzEncoder, ZlibEncoder};
use futures_core::ready;
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
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 {
let mut encoder = match futures::ready!(Pin::new(fut).poll(cx)) {
let mut encoder = match ready!(Pin::new(fut).poll(cx)) {
Ok(item) => item,
Err(e) => return Poll::Ready(Some(Err(e.into()))),
};

View file

@ -10,7 +10,7 @@ pub use actix_threadpool::BlockingError;
use actix_utils::timeout::TimeoutError;
use bytes::BytesMut;
use derive_more::{Display, From};
pub use futures::channel::oneshot::Canceled;
pub use futures_channel::oneshot::Canceled;
use http::uri::InvalidUri;
use http::{header, Error as HttpError, StatusCode};
use httparse;

View file

@ -195,17 +195,11 @@ impl Encoder for Codec {
#[cfg(test)]
mod tests {
use std::{cmp, io};
use actix_codec::{AsyncRead, AsyncWrite};
use bytes::{Buf, Bytes, BytesMut};
use http::{Method, Version};
use bytes::BytesMut;
use http::Method;
use super::*;
use crate::error::ParseError;
use crate::h1::Message;
use crate::httpmessage::HttpMessage;
use crate::request::Request;
#[test]
fn test_http_request_chunked_payload_and_next_message() {

View file

@ -912,7 +912,7 @@ where
#[cfg(test)]
mod tests {
use actix_service::IntoService;
use futures::future::{lazy, ok};
use futures_util::future::{lazy, ok};
use super::*;
use crate::error::Error;

View file

@ -521,12 +521,14 @@ fn write_camel_case(value: &[u8], buffer: &mut [u8]) {
#[cfg(test)]
mod tests {
use std::rc::Rc;
use bytes::Bytes;
//use std::rc::Rc;
use http::header::AUTHORIZATION;
use super::*;
use crate::http::header::{HeaderValue, CONTENT_TYPE};
use http::header::AUTHORIZATION;
use crate::RequestHead;
#[test]
fn test_chunked_te() {

View file

@ -1,7 +1,7 @@
use std::task::{Context, Poll};
use actix_service::{Service, ServiceFactory};
use futures::future::{ok, Ready};
use futures_util::future::{ok, Ready};
use crate::error::Error;
use crate::request::Request;

View file

@ -7,7 +7,7 @@ use std::task::{Context, Poll};
use actix_utils::task::LocalWaker;
use bytes::Bytes;
use futures::Stream;
use futures_core::Stream;
use crate::error::PayloadError;
@ -226,7 +226,7 @@ impl Inner {
#[cfg(test)]
mod tests {
use super::*;
use futures::future::poll_fn;
use futures_util::future::poll_fn;
#[actix_rt::test]
async fn test_unread_data() {

View file

@ -8,8 +8,8 @@ use std::{fmt, net};
use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::net::TcpStream;
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
use futures::future::{ok, Ready};
use futures::ready;
use futures_core::ready;
use futures_util::future::{ok, Ready};
use crate::body::MessageBody;
use crate::cloneable::CloneableService;

View file

@ -3,7 +3,7 @@ use std::task::{Context, Poll};
use actix_codec::Framed;
use actix_service::{Service, ServiceFactory};
use futures::future::Ready;
use futures_util::future::Ready;
use crate::error::Error;
use crate::h1::Codec;

View file

@ -3,7 +3,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use bytes::Bytes;
use futures::Stream;
use futures_core::Stream;
use h2::RecvStream;
mod dispatcher;

View file

@ -11,8 +11,8 @@ use actix_service::{
ServiceFactory,
};
use bytes::Bytes;
use futures::future::ok;
use futures::ready;
use futures_core::ready;
use futures_util::future::ok;
use h2::server::{self, Handshake};
use log::error;
@ -141,9 +141,9 @@ mod openssl {
#[cfg(feature = "rustls")]
mod rustls {
use super::*;
use actix_tls::rustls::{Acceptor, ServerConfig, Session, TlsStream};
use actix_tls::rustls::{Acceptor, ServerConfig, TlsStream};
use actix_tls::SslError;
use std::{fmt, io};
use std::io;
impl<S, B> H2Service<TlsStream<TcpStream>, S, B>
where

View file

@ -2,7 +2,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use bytes::Bytes;
use futures::Stream;
use futures_core::Stream;
use h2::RecvStream;
use crate::error::PayloadError;

View file

@ -7,7 +7,7 @@ use std::task::{Context, Poll};
use std::{fmt, str};
use bytes::{Bytes, BytesMut};
use futures::stream::Stream;
use futures_core::Stream;
use serde::Serialize;
use serde_json;

View file

@ -7,7 +7,8 @@ use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::net::TcpStream;
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
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 pin_project::{pin_project, project};

View file

@ -1,5 +1,9 @@
# Changes
## [1.0.0] - 2019-12-13
* Release
## [1.0.0-alpha.3]
* Migrate to `std::future`

View file

@ -42,7 +42,7 @@ actix-rt = "1.0.0"
base64 = "0.11"
bytes = "0.5.2"
derive_more = "0.99.2"
futures = "0.3.1"
futures-core = "0.3.1"
log =" 0.4"
mime = "0.3"
percent-encoding = "2.1"
@ -63,5 +63,6 @@ actix-server = "1.0.0"
actix-tls = { version = "1.0.0", features=["openssl", "rustls"] }
brotli = "3.3.0"
flate2 = "1.0.13"
futures = "0.3.1"
env_logger = "0.6"
webpki = "0.21"

View file

@ -1,3 +1,4 @@
use std::future::Future;
use std::pin::Pin;
use std::rc::Rc;
use std::task::{Context, Poll};
@ -12,7 +13,6 @@ use actix_http::h1::ClientCodec;
use actix_http::http::HeaderMap;
use actix_http::{RequestHead, RequestHeadType, ResponseHead};
use actix_service::Service;
use futures::future::{FutureExt, LocalBoxFuture};
use crate::response::ClientResponse;
@ -24,7 +24,7 @@ pub(crate) trait Connect {
head: RequestHead,
body: Body,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>;
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>;
fn send_request_extra(
&mut self,
@ -32,16 +32,22 @@ pub(crate) trait Connect {
extra_headers: Option<HeaderMap>,
body: Body,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>;
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>;
/// Send request, returns Response and Framed
fn open_tunnel(
&mut self,
head: RequestHead,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<
'static,
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
) -> Pin<
Box<
dyn Future<
Output = Result<
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
SendRequestError,
>,
>,
>,
>;
/// Send request and extra headers, returns Response and Framed
@ -50,9 +56,15 @@ pub(crate) trait Connect {
head: Rc<RequestHead>,
extra_headers: Option<HeaderMap>,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<
'static,
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
) -> Pin<
Box<
dyn Future<
Output = Result<
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
SendRequestError,
>,
>,
>,
>;
}
@ -70,14 +82,14 @@ where
head: RequestHead,
body: Body,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>> {
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>> {
// connect to the host
let fut = self.0.call(ClientConnect {
uri: head.uri.clone(),
addr,
});
async move {
Box::pin(async move {
let connection = fut.await?;
// send request
@ -85,8 +97,7 @@ where
.send_request(RequestHeadType::from(head), body)
.await
.map(|(head, payload)| ClientResponse::new(head, payload))
}
.boxed_local()
})
}
fn send_request_extra(
@ -95,14 +106,14 @@ where
extra_headers: Option<HeaderMap>,
body: Body,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>> {
) -> Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>> {
// connect to the host
let fut = self.0.call(ClientConnect {
uri: head.uri.clone(),
addr,
});
async move {
Box::pin(async move {
let connection = fut.await?;
// send request
@ -111,17 +122,22 @@ where
.await?;
Ok(ClientResponse::new(head, payload))
}
.boxed_local()
})
}
fn open_tunnel(
&mut self,
head: RequestHead,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<
'static,
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
) -> Pin<
Box<
dyn Future<
Output = Result<
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
SendRequestError,
>,
>,
>,
> {
// connect to the host
let fut = self.0.call(ClientConnect {
@ -129,7 +145,7 @@ where
addr,
});
async move {
Box::pin(async move {
let connection = fut.await?;
// send request
@ -138,8 +154,7 @@ where
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
Ok((head, framed))
}
.boxed_local()
})
}
fn open_tunnel_extra(
@ -147,9 +162,15 @@ where
head: Rc<RequestHead>,
extra_headers: Option<HeaderMap>,
addr: Option<net::SocketAddr>,
) -> LocalBoxFuture<
'static,
Result<(ResponseHead, Framed<BoxedSocket, ClientCodec>), SendRequestError>,
) -> Pin<
Box<
dyn Future<
Output = Result<
(ResponseHead, Framed<BoxedSocket, ClientCodec>),
SendRequestError,
>,
>,
>,
> {
// connect to the host
let fut = self.0.call(ClientConnect {
@ -157,7 +178,7 @@ where
addr,
});
async move {
Box::pin(async move {
let connection = fut.await?;
// send request
@ -167,8 +188,7 @@ where
let framed = framed.map_io(|io| BoxedSocket(Box::new(Socket(io))));
Ok((head, framed))
}
.boxed_local()
})
}
}

View file

@ -4,7 +4,7 @@ use std::rc::Rc;
use std::time::Duration;
use bytes::Bytes;
use futures::Stream;
use futures_core::Stream;
use serde::Serialize;
use actix_http::body::Body;

View file

@ -5,7 +5,7 @@ use std::time::Duration;
use std::{fmt, net};
use bytes::Bytes;
use futures::Stream;
use futures_core::Stream;
use percent_encoding::percent_encode;
use serde::Serialize;

View file

@ -5,7 +5,7 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use bytes::{Bytes, BytesMut};
use futures::{ready, Future, Stream};
use futures_core::{ready, Future, Stream};
use actix_http::cookie::Cookie;
use actix_http::error::{CookieParseError, PayloadError};

View file

@ -7,7 +7,7 @@ use std::time::Duration;
use actix_rt::time::{delay_for, Delay};
use bytes::Bytes;
use derive_more::From;
use futures::{future::LocalBoxFuture, ready, Future, Stream};
use futures_core::{ready, Future, Stream};
use serde::Serialize;
use serde_json;
@ -49,7 +49,7 @@ impl Into<SendRequestError> for PrepForSendingError {
#[must_use = "futures do nothing unless polled"]
pub enum SendClientRequest {
Fut(
LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>,
Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>,
Option<Delay>,
bool,
),
@ -58,7 +58,7 @@ pub enum SendClientRequest {
impl SendClientRequest {
pub(crate) fn new(
send: LocalBoxFuture<'static, Result<ClientResponse, SendRequestError>>,
send: Pin<Box<dyn Future<Output = Result<ClientResponse, SendRequestError>>>>,
response_decompress: bool,
timeout: Option<Duration>,
) -> SendClientRequest {