mirror of https://github.com/fafhrd91/actix-web
Merge pull request #59 from actix/master
actix#1514 actix#1491 actix#1515 actix#1518
This commit is contained in:
commit
050052fa5a
|
@ -14,6 +14,8 @@
|
||||||
|
|
||||||
* Bump minimum supported Rust version to 1.40
|
* Bump minimum supported Rust version to 1.40
|
||||||
|
|
||||||
|
* Replace deprecated `net2` crate with `socket2`
|
||||||
|
|
||||||
[#1485]: https://github.com/actix/actix-web/pull/1485
|
[#1485]: https://github.com/actix/actix-web/pull/1485
|
||||||
[#1509]: https://github.com/actix/actix-web/pull/1509
|
[#1509]: https://github.com/actix/actix-web/pull/1509
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,13 @@ awc = { version = "2.0.0-alpha.1", default-features = false }
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures = "0.3.1"
|
futures-channel = { version = "0.3.5", default-features = false }
|
||||||
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
fxhash = "0.2.1"
|
fxhash = "0.2.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
net2 = "0.2.33"
|
socket2 = "0.3"
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.6"
|
||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
serde = { version = "1.0", features=["derive"] }
|
serde = { version = "1.0", features=["derive"] }
|
||||||
|
|
|
@ -3,8 +3,14 @@
|
||||||
* Setting a cookie's SameSite property, explicitly, to `SameSite::None` will now
|
* Setting a cookie's SameSite property, explicitly, to `SameSite::None` will now
|
||||||
result in `SameSite=None` being sent with the response Set-Cookie header.
|
result in `SameSite=None` being sent with the response Set-Cookie header.
|
||||||
To create a cookie without a SameSite attribute, remove any calls setting same_site.
|
To create a cookie without a SameSite attribute, remove any calls setting same_site.
|
||||||
|
|
||||||
* actix-http support for Actors messages was moved to actix-http crate and is enabled
|
* actix-http support for Actors messages was moved to actix-http crate and is enabled
|
||||||
with feature `actors`
|
with feature `actors`
|
||||||
|
* content_length function is removed from actix-http.
|
||||||
|
You can set Content-Length by normally setting the response body or calling no_chunking function.
|
||||||
|
|
||||||
|
* `BodySize::Sized64` variant has been removed. `BodySize::Sized` now receives a
|
||||||
|
`u64` instead of a `usize`.
|
||||||
|
|
||||||
## 2.0.0
|
## 2.0.0
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,8 @@ actix-http = "2.0.0-alpha.3"
|
||||||
actix-service = "1.0.1"
|
actix-service = "1.0.1"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
|
|
|
@ -24,8 +24,8 @@ use actix_web::http::header::{self, DispositionType};
|
||||||
use actix_web::http::Method;
|
use actix_web::http::Method;
|
||||||
use actix_web::{web, FromRequest, HttpRequest, HttpResponse};
|
use actix_web::{web, FromRequest, HttpRequest, HttpResponse};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, ready, Either, FutureExt, LocalBoxFuture, Ready};
|
use futures_core::Stream;
|
||||||
use futures::Stream;
|
use futures_util::future::{ok, ready, Either, FutureExt, LocalBoxFuture, Ready};
|
||||||
use mime;
|
use mime;
|
||||||
use mime_guess::from_ext;
|
use mime_guess::from_ext;
|
||||||
use percent_encoding::{utf8_percent_encode, CONTROLS};
|
use percent_encoding::{utf8_percent_encode, CONTROLS};
|
||||||
|
|
|
@ -18,7 +18,7 @@ use actix_web::http::header::{
|
||||||
};
|
};
|
||||||
use actix_web::http::{ContentEncoding, StatusCode};
|
use actix_web::http::{ContentEncoding, StatusCode};
|
||||||
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
|
use actix_web::{Error, HttpMessage, HttpRequest, HttpResponse, Responder};
|
||||||
use futures::future::{ready, Ready};
|
use futures_util::future::{ready, Ready};
|
||||||
|
|
||||||
use crate::range::HttpRange;
|
use crate::range::HttpRange;
|
||||||
use crate::ChunkedReadFile;
|
use crate::ChunkedReadFile;
|
||||||
|
|
|
@ -26,7 +26,7 @@ actix-rt = "1.0.0"
|
||||||
actix-http = "2.0.0-alpha.3"
|
actix-http = "2.0.0-alpha.3"
|
||||||
|
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.6"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use actix_http::h1::{Codec, SendResponse};
|
||||||
use actix_http::{Error, Request, Response};
|
use actix_http::{Error, Request, Response};
|
||||||
use actix_router::{Path, Router, Url};
|
use actix_router::{Path, Router, Url};
|
||||||
use actix_service::{IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{IntoServiceFactory, Service, ServiceFactory};
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture};
|
use futures_util::future::{ok, FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
use crate::helpers::{BoxedHttpNewService, BoxedHttpService, HttpNewService};
|
use crate::helpers::{BoxedHttpNewService, BoxedHttpService, HttpNewService};
|
||||||
use crate::request::FramedRequest;
|
use crate::request::FramedRequest;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::Error;
|
use actix_http::Error;
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{FutureExt, LocalBoxFuture};
|
use futures_util::future::{FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
pub(crate) type BoxedHttpService<Req> = Box<
|
pub(crate) type BoxedHttpService<Req> = Box<
|
||||||
dyn Service<
|
dyn Service<
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::task::{Context, Poll};
|
||||||
use actix_codec::{AsyncRead, AsyncWrite};
|
use actix_codec::{AsyncRead, AsyncWrite};
|
||||||
use actix_http::{http::Method, Error};
|
use actix_http::{http::Method, Error};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
use log::error;
|
use log::error;
|
||||||
|
|
||||||
use crate::app::HttpServiceFactory;
|
use crate::app::HttpServiceFactory;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
@ -9,8 +10,7 @@ use actix_http::h1::{Codec, Message};
|
||||||
use actix_http::ws::{verify_handshake, HandshakeError};
|
use actix_http::ws::{verify_handshake, HandshakeError};
|
||||||
use actix_http::{Request, Response};
|
use actix_http::{Request, Response};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{err, ok, Either, Ready};
|
use futures_util::future::{err, ok, Either, Ready};
|
||||||
use futures::Future;
|
|
||||||
|
|
||||||
/// Service that verifies incoming request if it is valid websocket
|
/// Service that verifies incoming request if it is valid websocket
|
||||||
/// upgrade request. In case of error returns `HandshakeError`
|
/// upgrade request. In case of error returns `HandshakeError`
|
||||||
|
|
|
@ -4,7 +4,7 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{pipeline_factory, IntoServiceFactory, ServiceFactory};
|
use actix_service::{pipeline_factory, IntoServiceFactory, ServiceFactory};
|
||||||
use actix_utils::framed::Dispatcher;
|
use actix_utils::framed::Dispatcher;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::{future, SinkExt, StreamExt};
|
use futures_util::{future, SinkExt, StreamExt};
|
||||||
|
|
||||||
use actix_framed::{FramedApp, FramedRequest, FramedRoute, SendError, VerifyWebSockets};
|
use actix_framed::{FramedApp, FramedRequest, FramedRoute, SendError, VerifyWebSockets};
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,18 @@
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
* Bump minimum supported Rust version to 1.40
|
* Bump minimum supported Rust version to 1.40
|
||||||
|
* content_length function is removed, and you can set Content-Length by calling no_chunking function [#1439]
|
||||||
|
|
||||||
|
* `BodySize::Sized64` variant has been removed. `BodySize::Sized` now receives a
|
||||||
|
`u64` instead of a `usize`.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Support parsing of `SameSite=None` [#1503]
|
* Support parsing of `SameSite=None` [#1503]
|
||||||
|
|
||||||
|
[#1439]: https://github.com/actix/actix-web/pull/1439
|
||||||
|
[#1503]: https://github.com/actix/actix-web/pull/1503
|
||||||
|
|
||||||
## [2.0.0-alpha.3] - 2020-05-08
|
## [2.0.0-alpha.3] - 2020-05-08
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -56,9 +56,9 @@ copyless = "0.1.4"
|
||||||
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-core = "0.3.1"
|
futures-channel = { version = "0.3.5", default-features = false }
|
||||||
futures-util = "0.3.1"
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
futures-channel = "0.3.1"
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
fxhash = "0.2.1"
|
fxhash = "0.2.1"
|
||||||
h2 = "0.2.1"
|
h2 = "0.2.1"
|
||||||
http = "0.2.0"
|
http = "0.2.0"
|
||||||
|
@ -88,11 +88,10 @@ flate2 = { version = "1.0.13", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-server = "1.0.1"
|
actix-server = "1.0.1"
|
||||||
actix-connect = { version = "2.0.0-alpha.2", features=["openssl"] }
|
actix-connect = { version = "2.0.0-alpha.2", features = ["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0", features=["openssl"] }
|
actix-http-test = { version = "1.0.0", features = ["openssl"] }
|
||||||
actix-tls = { version = "2.0.0-alpha.1", features=["openssl"] }
|
actix-tls = { version = "2.0.0-alpha.1", features = ["openssl"] }
|
||||||
criterion = "0.3"
|
criterion = "0.3"
|
||||||
futures = "0.3.1"
|
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
open-ssl = { version="0.10", package = "openssl" }
|
open-ssl = { version="0.10", package = "openssl" }
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{env, io};
|
||||||
use actix_http::{Error, HttpService, Request, Response};
|
use actix_http::{Error, HttpService, Request, Response};
|
||||||
use actix_server::Server;
|
use actix_server::Server;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use http::header::HeaderValue;
|
use http::header::HeaderValue;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use actix_http::http::HeaderValue;
|
||||||
use actix_http::{Error, HttpService, Request, Response};
|
use actix_http::{Error, HttpService, Request, Response};
|
||||||
use actix_server::Server;
|
use actix_server::Server;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
async fn handle_request(mut req: Request) -> Result<Response, Error> {
|
async fn handle_request(mut req: Request) -> Result<Response, Error> {
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::{env, io};
|
||||||
|
|
||||||
use actix_http::{HttpService, Response};
|
use actix_http::{HttpService, Response};
|
||||||
use actix_server::Server;
|
use actix_server::Server;
|
||||||
use futures::future;
|
use futures_util::future;
|
||||||
use http::header::HeaderValue;
|
use http::header::HeaderValue;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,7 @@ use crate::error::Error;
|
||||||
pub enum BodySize {
|
pub enum BodySize {
|
||||||
None,
|
None,
|
||||||
Empty,
|
Empty,
|
||||||
Sized(usize),
|
Sized(u64),
|
||||||
Sized64(u64),
|
|
||||||
Stream,
|
Stream,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +24,7 @@ impl BodySize {
|
||||||
match self {
|
match self {
|
||||||
BodySize::None
|
BodySize::None
|
||||||
| BodySize::Empty
|
| BodySize::Empty
|
||||||
| BodySize::Sized(0)
|
| BodySize::Sized(0) => true,
|
||||||
| BodySize::Sized64(0) => true,
|
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +168,7 @@ impl MessageBody for Body {
|
||||||
match self {
|
match self {
|
||||||
Body::None => BodySize::None,
|
Body::None => BodySize::None,
|
||||||
Body::Empty => BodySize::Empty,
|
Body::Empty => BodySize::Empty,
|
||||||
Body::Bytes(ref bin) => BodySize::Sized(bin.len()),
|
Body::Bytes(ref bin) => BodySize::Sized(bin.len() as u64),
|
||||||
Body::Message(ref body) => body.size(),
|
Body::Message(ref body) => body.size(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -297,7 +295,7 @@ where
|
||||||
|
|
||||||
impl MessageBody for Bytes {
|
impl MessageBody for Bytes {
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized(self.len())
|
BodySize::Sized(self.len() as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -314,7 +312,7 @@ impl MessageBody for Bytes {
|
||||||
|
|
||||||
impl MessageBody for BytesMut {
|
impl MessageBody for BytesMut {
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized(self.len())
|
BodySize::Sized(self.len() as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -331,7 +329,7 @@ impl MessageBody for BytesMut {
|
||||||
|
|
||||||
impl MessageBody for &'static str {
|
impl MessageBody for &'static str {
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized(self.len())
|
BodySize::Sized(self.len() as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -350,7 +348,7 @@ impl MessageBody for &'static str {
|
||||||
|
|
||||||
impl MessageBody for Vec<u8> {
|
impl MessageBody for Vec<u8> {
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized(self.len())
|
BodySize::Sized(self.len() as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -367,7 +365,7 @@ impl MessageBody for Vec<u8> {
|
||||||
|
|
||||||
impl MessageBody for String {
|
impl MessageBody for String {
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized(self.len())
|
BodySize::Sized(self.len() as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -458,7 +456,7 @@ where
|
||||||
S: Stream<Item = Result<Bytes, Error>> + Unpin,
|
S: Stream<Item = Result<Bytes, Error>> + Unpin,
|
||||||
{
|
{
|
||||||
fn size(&self) -> BodySize {
|
fn size(&self) -> BodySize {
|
||||||
BodySize::Sized64(self.size)
|
BodySize::Sized(self.size as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attempts to pull out the next value of the underlying [`Stream`].
|
/// Attempts to pull out the next value of the underlying [`Stream`].
|
||||||
|
@ -484,7 +482,7 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use futures::stream;
|
use futures_util::stream;
|
||||||
use futures_util::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
use futures_util::pin_mut;
|
use futures_util::pin_mut;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use std::{fmt, io, mem, time};
|
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_util::future::{err, Either, Future, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{err, Either, FutureExt, LocalBoxFuture, Ready};
|
||||||
use h2::client::SendRequest;
|
use h2::client::SendRequest;
|
||||||
use pin_project::{pin_project, project};
|
use pin_project::{pin_project, project};
|
||||||
|
|
||||||
|
|
|
@ -64,10 +64,6 @@ where
|
||||||
CONTENT_LENGTH,
|
CONTENT_LENGTH,
|
||||||
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
||||||
),
|
),
|
||||||
BodySize::Sized64(len) => req.headers_mut().insert(
|
|
||||||
CONTENT_LENGTH,
|
|
||||||
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extracting extra headers from RequestHeadType. HeaderMap::new() does not allocate.
|
// Extracting extra headers from RequestHeadType. HeaderMap::new() does not allocate.
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::ptr::copy_nonoverlapping;
|
||||||
use std::slice::from_raw_parts_mut;
|
use std::slice::from_raw_parts_mut;
|
||||||
use std::{cmp, io};
|
use std::{cmp, io};
|
||||||
|
|
||||||
use bytes::{buf::BufMutExt, BufMut, BytesMut};
|
use bytes::{BufMut, BytesMut};
|
||||||
|
|
||||||
use crate::body::BodySize;
|
use crate::body::BodySize;
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
|
@ -95,15 +95,6 @@ pub(crate) trait MessageType: Sized {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BodySize::Sized(len) => helpers::write_content_length(len, dst),
|
BodySize::Sized(len) => helpers::write_content_length(len, dst),
|
||||||
BodySize::Sized64(len) => {
|
|
||||||
if camel_case {
|
|
||||||
dst.put_slice(b"\r\nContent-Length: ");
|
|
||||||
} else {
|
|
||||||
dst.put_slice(b"\r\ncontent-length: ");
|
|
||||||
}
|
|
||||||
#[allow(clippy::write_with_newline)]
|
|
||||||
write!(dst.writer(), "{}\r\n", len)?;
|
|
||||||
}
|
|
||||||
BodySize::None => dst.put_slice(b"\r\n"),
|
BodySize::None => dst.put_slice(b"\r\n"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,8 +329,7 @@ impl<T: MessageType> MessageEncoder<T> {
|
||||||
if !head {
|
if !head {
|
||||||
self.te = match length {
|
self.te = match length {
|
||||||
BodySize::Empty => TransferEncoding::empty(),
|
BodySize::Empty => TransferEncoding::empty(),
|
||||||
BodySize::Sized(len) => TransferEncoding::length(len as u64),
|
BodySize::Sized(len) => TransferEncoding::length(len),
|
||||||
BodySize::Sized64(len) => TransferEncoding::length(len),
|
|
||||||
BodySize::Stream => {
|
BodySize::Stream => {
|
||||||
if message.chunked() && !stream {
|
if message.chunked() && !stream {
|
||||||
TransferEncoding::chunked()
|
TransferEncoding::chunked()
|
||||||
|
@ -582,19 +572,6 @@ mod tests {
|
||||||
assert!(data.contains("Content-Type: plain/text\r\n"));
|
assert!(data.contains("Content-Type: plain/text\r\n"));
|
||||||
assert!(data.contains("Date: date\r\n"));
|
assert!(data.contains("Date: date\r\n"));
|
||||||
|
|
||||||
let _ = head.encode_headers(
|
|
||||||
&mut bytes,
|
|
||||||
Version::HTTP_11,
|
|
||||||
BodySize::Sized64(100),
|
|
||||||
ConnectionType::KeepAlive,
|
|
||||||
&ServiceConfig::default(),
|
|
||||||
);
|
|
||||||
let data =
|
|
||||||
String::from_utf8(Vec::from(bytes.split().freeze().as_ref())).unwrap();
|
|
||||||
assert!(data.contains("Content-Length: 100\r\n"));
|
|
||||||
assert!(data.contains("Content-Type: plain/text\r\n"));
|
|
||||||
assert!(data.contains("Date: date\r\n"));
|
|
||||||
|
|
||||||
let mut head = RequestHead::default();
|
let mut head = RequestHead::default();
|
||||||
head.set_camel_case_headers(false);
|
head.set_camel_case_headers(false);
|
||||||
head.headers.insert(DATE, HeaderValue::from_static("date"));
|
head.headers.insert(DATE, HeaderValue::from_static("date"));
|
||||||
|
|
|
@ -210,10 +210,6 @@ where
|
||||||
CONTENT_LENGTH,
|
CONTENT_LENGTH,
|
||||||
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
||||||
),
|
),
|
||||||
BodySize::Sized64(len) => res.headers_mut().insert(
|
|
||||||
CONTENT_LENGTH,
|
|
||||||
HeaderValue::try_from(format!("{}", len)).unwrap(),
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// copy headers
|
// copy headers
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub(crate) fn write_status_line(version: Version, n: u16, bytes: &mut BytesMut)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE: bytes object has to contain enough space
|
/// NOTE: bytes object has to contain enough space
|
||||||
pub fn write_content_length(n: usize, bytes: &mut BytesMut) {
|
pub fn write_content_length(n: u64, bytes: &mut BytesMut) {
|
||||||
bytes.put_slice(b"\r\ncontent-length: ");
|
bytes.put_slice(b"\r\ncontent-length: ");
|
||||||
|
|
||||||
if n < 10 {
|
if n < 10 {
|
||||||
|
@ -96,16 +96,16 @@ pub fn write_content_length(n: usize, bytes: &mut BytesMut) {
|
||||||
bytes.put_u8(DIGITS_START + d10);
|
bytes.put_u8(DIGITS_START + d10);
|
||||||
bytes.put_u8(DIGITS_START + d1);
|
bytes.put_u8(DIGITS_START + d1);
|
||||||
} else {
|
} else {
|
||||||
write_usize(n, bytes);
|
write_u64(n, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes.put_slice(b"\r\n");
|
bytes.put_slice(b"\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn write_usize(n: usize, bytes: &mut BytesMut) {
|
pub(crate) fn write_u64(n: u64, bytes: &mut BytesMut) {
|
||||||
let mut n = n;
|
let mut n = n;
|
||||||
|
|
||||||
// 20 chars is max length of a usize (2^64)
|
// 20 chars is max length of a u64 (2^64)
|
||||||
// digits will be added to the buffer from lsd to msd
|
// digits will be added to the buffer from lsd to msd
|
||||||
let mut buf = BytesMut::with_capacity(20);
|
let mut buf = BytesMut::with_capacity(20);
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,9 @@ impl ResponseBuilder {
|
||||||
|
|
||||||
/// Disable chunked transfer encoding for HTTP/1.1 streaming responses.
|
/// Disable chunked transfer encoding for HTTP/1.1 streaming responses.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn no_chunking(&mut self) -> &mut Self {
|
pub fn no_chunking(&mut self, len: u64) -> &mut Self {
|
||||||
|
self.header(header::CONTENT_LENGTH, len);
|
||||||
|
|
||||||
if let Some(parts) = parts(&mut self.head, &self.err) {
|
if let Some(parts) = parts(&mut self.head, &self.err) {
|
||||||
parts.no_chunking(true);
|
parts.no_chunking(true);
|
||||||
}
|
}
|
||||||
|
@ -497,12 +499,6 @@ impl ResponseBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set content length
|
|
||||||
#[inline]
|
|
||||||
pub fn content_length(&mut self, len: u64) -> &mut Self {
|
|
||||||
self.header(header::CONTENT_LENGTH, len)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set a cookie
|
/// Set a cookie
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use actix_service::ServiceFactory;
|
use actix_service::ServiceFactory;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{self, ok};
|
use futures_util::future::{self, ok};
|
||||||
|
|
||||||
use actix_http::{http, HttpService, Request, Response};
|
use actix_http::{http, HttpService, Request, Response};
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
|
|
|
@ -5,8 +5,8 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{fn_service, ServiceFactory};
|
use actix_service::{fn_service, ServiceFactory};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::{err, ok, ready};
|
use futures_util::future::{err, ok, ready};
|
||||||
use futures::stream::{once, Stream, StreamExt};
|
use futures_util::stream::{once, Stream, StreamExt};
|
||||||
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
|
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
|
||||||
|
|
||||||
use actix_http::error::{ErrorBadRequest, PayloadError};
|
use actix_http::error::{ErrorBadRequest, PayloadError};
|
||||||
|
@ -275,7 +275,7 @@ async fn test_h2_head_binary() {
|
||||||
let mut srv = test_server(move || {
|
let mut srv = test_server(move || {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(|_| {
|
.h2(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.openssl(ssl_acceptor())
|
.openssl(ssl_acceptor())
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
|
|
|
@ -7,8 +7,8 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{fn_factory_with_config, fn_service};
|
use actix_service::{fn_factory_with_config, fn_service};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::{self, err, ok};
|
use futures_util::future::{self, err, ok};
|
||||||
use futures::stream::{once, Stream, StreamExt};
|
use futures_util::stream::{once, Stream, StreamExt};
|
||||||
use rust_tls::{
|
use rust_tls::{
|
||||||
internal::pemfile::{certs, pkcs8_private_keys},
|
internal::pemfile::{certs, pkcs8_private_keys},
|
||||||
NoClientAuth, ServerConfig as RustlsServerConfig,
|
NoClientAuth, ServerConfig as RustlsServerConfig,
|
||||||
|
@ -281,7 +281,7 @@ async fn test_h2_head_binary() {
|
||||||
let mut srv = test_server(move || {
|
let mut srv = test_server(move || {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h2(|_| {
|
.h2(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.rustls(ssl_acceptor())
|
.rustls(ssl_acceptor())
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,8 +6,8 @@ use actix_http_test::test_server;
|
||||||
use actix_rt::time::delay_for;
|
use actix_rt::time::delay_for;
|
||||||
use actix_service::fn_service;
|
use actix_service::fn_service;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{self, err, ok, ready, FutureExt};
|
use futures_util::future::{self, err, ok, ready, FutureExt};
|
||||||
use futures::stream::{once, StreamExt};
|
use futures_util::stream::{once, StreamExt};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use actix_http::httpmessage::HttpMessage;
|
use actix_http::httpmessage::HttpMessage;
|
||||||
|
@ -490,7 +490,7 @@ async fn test_h1_head_binary() {
|
||||||
let mut srv = test_server(|| {
|
let mut srv = test_server(|| {
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.h1(|_| {
|
.h1(|_| {
|
||||||
ok::<_, ()>(Response::Ok().content_length(STR.len() as u64).body(STR))
|
ok::<_, ()>(Response::Ok().body(STR))
|
||||||
})
|
})
|
||||||
.tcp()
|
.tcp()
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
@ -9,9 +10,9 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{fn_factory, Service};
|
use actix_service::{fn_factory, Service};
|
||||||
use actix_utils::framed::Dispatcher;
|
use actix_utils::framed::Dispatcher;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future;
|
use futures_util::future;
|
||||||
use futures::task::{Context, Poll};
|
use futures_util::task::{Context, Poll};
|
||||||
use futures::{Future, SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
struct WsService<T>(Arc<Mutex<(PhantomData<T>, Cell<bool>)>>);
|
struct WsService<T>(Arc<Mutex<(PhantomData<T>, Cell<bool>)>>);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ actix-utils = "1.0.3"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
futures = "0.3.1"
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
twoway = "0.2"
|
twoway = "0.2"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Multipart payload support
|
//! Multipart payload support
|
||||||
use actix_web::{dev::Payload, Error, FromRequest, HttpRequest};
|
use actix_web::{dev::Payload, Error, FromRequest, HttpRequest};
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
|
|
||||||
use crate::server::Multipart;
|
use crate::server::Multipart;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use crate::server::Multipart;
|
||||||
/// ## Server example
|
/// ## Server example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use futures::{Stream, StreamExt};
|
/// use futures_util::stream::{Stream, StreamExt};
|
||||||
/// use actix_web::{web, HttpResponse, Error};
|
/// use actix_web::{web, HttpResponse, Error};
|
||||||
/// use actix_multipart as mp;
|
/// use actix_multipart as mp;
|
||||||
///
|
///
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::task::{Context, Poll};
|
||||||
use std::{cmp, fmt};
|
use std::{cmp, fmt};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::stream::{LocalBoxStream, Stream, StreamExt};
|
use futures_util::stream::{LocalBoxStream, Stream, StreamExt};
|
||||||
use httparse;
|
use httparse;
|
||||||
use mime;
|
use mime;
|
||||||
|
|
||||||
|
@ -814,7 +814,7 @@ mod tests {
|
||||||
use actix_utils::mpsc;
|
use actix_utils::mpsc;
|
||||||
use actix_web::http::header::{DispositionParam, DispositionType};
|
use actix_web::http::header::{DispositionParam, DispositionType};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::lazy;
|
use futures_util::future::lazy;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_boundary() {
|
async fn test_boundary() {
|
||||||
|
|
|
@ -21,9 +21,11 @@ actix-web = "3.0.0-alpha.2"
|
||||||
actix-http = "2.0.0-alpha.3"
|
actix-http = "2.0.0-alpha.3"
|
||||||
actix-codec = "0.2.0"
|
actix-codec = "0.2.0"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
futures = "0.3.1"
|
futures-channel = { version = "0.3.5", default-features = false }
|
||||||
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
|
@ -11,8 +12,8 @@ use actix::{
|
||||||
};
|
};
|
||||||
use actix_web::error::Error;
|
use actix_web::error::Error;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::channel::oneshot::Sender;
|
use futures_channel::oneshot::Sender;
|
||||||
use futures::{Future, Stream};
|
use futures_core::Stream;
|
||||||
|
|
||||||
/// Execution context for http actors
|
/// Execution context for http actors
|
||||||
pub struct HttpContext<A>
|
pub struct HttpContext<A>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Websocket integration
|
//! Websocket integration
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
|
use std::future::Future;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
@ -23,8 +24,8 @@ use actix_web::error::{Error, PayloadError};
|
||||||
use actix_web::http::{header, Method, StatusCode};
|
use actix_web::http::{header, Method, StatusCode};
|
||||||
use actix_web::{HttpRequest, HttpResponse};
|
use actix_web::{HttpRequest, HttpResponse};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::channel::oneshot::Sender;
|
use futures_channel::oneshot::Sender;
|
||||||
use futures::{Future, Stream};
|
use futures_core::Stream;
|
||||||
|
|
||||||
/// Do websocket handshake and start ws actor.
|
/// Do websocket handshake and start ws actor.
|
||||||
pub fn start<A, T>(actor: A, req: &HttpRequest, stream: T) -> Result<HttpResponse, Error>
|
pub fn start<A, T>(actor: A, req: &HttpRequest, stream: T) -> Result<HttpResponse, Error>
|
||||||
|
|
|
@ -2,7 +2,7 @@ use actix::prelude::*;
|
||||||
use actix_web::{test, web, App, HttpRequest};
|
use actix_web::{test, web, App, HttpRequest};
|
||||||
use actix_web_actors::*;
|
use actix_web_actors::*;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
struct Ws;
|
struct Ws;
|
||||||
|
|
||||||
|
|
|
@ -19,4 +19,4 @@ proc-macro2 = "^1"
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0"
|
actix-rt = "1.0.0"
|
||||||
actix-web = "3.0.0-alpha.2"
|
actix-web = "3.0.0-alpha.2"
|
||||||
futures = "0.3.1"
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use actix_web::HttpResponse;
|
//! use actix_web::HttpResponse;
|
||||||
//! use actix_web_codegen::get;
|
//! use actix_web_codegen::get;
|
||||||
//! use futures::{future, Future};
|
|
||||||
//!
|
//!
|
||||||
//! #[get("/test")]
|
//! #[get("/test")]
|
||||||
//! async fn async_test() -> Result<HttpResponse, actix_web::Error> {
|
//! async fn async_test() -> Result<HttpResponse, actix_web::Error> {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::future::Future;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_web::{http, test, web::Path, App, HttpResponse, Responder, Error};
|
use actix_web::{http, test, web::Path, App, HttpResponse, Responder, Error};
|
||||||
use actix_web::dev::{Service, Transform, ServiceRequest, ServiceResponse};
|
use actix_web::dev::{Service, Transform, ServiceRequest, ServiceResponse};
|
||||||
use actix_web_codegen::{connect, delete, get, head, options, patch, post, put, trace};
|
use actix_web_codegen::{connect, delete, get, head, options, patch, post, put, trace};
|
||||||
use futures::{future, Future};
|
use futures_util::future;
|
||||||
use actix_web::http::header::{HeaderName, HeaderValue};
|
use actix_web::http::header::{HeaderName, HeaderValue};
|
||||||
|
|
||||||
// Make sure that we can name function as 'config'
|
// Make sure that we can name function as 'config'
|
||||||
|
|
|
@ -42,7 +42,7 @@ actix-rt = "1.0.0"
|
||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures-core = "0.3.1"
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
log =" 0.4"
|
log =" 0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1"
|
||||||
|
@ -63,6 +63,6 @@ actix-server = "1.0.0"
|
||||||
actix-tls = { version = "2.0.0-alpha.1", features = ["openssl", "rustls"] }
|
actix-tls = { version = "2.0.0-alpha.1", features = ["openssl", "rustls"] }
|
||||||
brotli2 = "0.3.2"
|
brotli2 = "0.3.2"
|
||||||
flate2 = "1.0.13"
|
flate2 = "1.0.13"
|
||||||
futures = "0.3.1"
|
futures-util = { version = "0.3.5", default-features = false }
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
webpki = "0.21"
|
webpki = "0.21"
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
//! An HTTP Client
|
//! An HTTP Client
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust
|
||||||
//! use futures::future::{lazy, Future};
|
|
||||||
//! use actix_rt::System;
|
//! use actix_rt::System;
|
||||||
//! use awc::Client;
|
//! use awc::Client;
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl ClientRequest {
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// # actix_rt::System::new("test").block_on(futures::future::lazy(|_| {
|
/// # actix_rt::System::new("test").block_on(futures_util::future::lazy(|_| {
|
||||||
/// let req = awc::Client::new()
|
/// let req = awc::Client::new()
|
||||||
/// .get("http://www.rust-lang.org")
|
/// .get("http://www.rust-lang.org")
|
||||||
/// .set(awc::http::header::Date::now())
|
/// .set(awc::http::header::Date::now())
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use std::cell::{Ref, RefMut};
|
use std::cell::{Ref, RefMut};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures_core::{ready, Future, Stream};
|
use futures_core::{ready, Stream};
|
||||||
|
|
||||||
use actix_http::cookie::Cookie;
|
use actix_http::cookie::Cookie;
|
||||||
use actix_http::error::{CookieParseError, PayloadError};
|
use actix_http::error::{CookieParseError, PayloadError};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::future::Future;
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -7,7 +8,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_core::{Future, Stream};
|
use futures_core::Stream;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use actix_http::body::{Body, BodyStream};
|
use actix_http::body::{Body, BodyStream};
|
||||||
|
|
|
@ -9,7 +9,7 @@ use bytes::Bytes;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use flate2::write::GzEncoder;
|
use flate2::write::GzEncoder;
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use actix_http::HttpService;
|
use actix_http::HttpService;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslVerifyMode};
|
use open_ssl::ssl::{SslAcceptor, SslFiletype, SslMethod, SslVerifyMode};
|
||||||
use rust_tls::ClientConfig;
|
use rust_tls::ClientConfig;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use actix_http_test::test_server;
|
||||||
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
use actix_service::{map_config, pipeline_factory, ServiceFactory};
|
||||||
use actix_web::http::Version;
|
use actix_web::http::Version;
|
||||||
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
use actix_web::{dev::AppConfig, web, App, HttpResponse};
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
|
use open_ssl::ssl::{SslAcceptor, SslConnector, SslFiletype, SslMethod, SslVerifyMode};
|
||||||
|
|
||||||
fn ssl_acceptor() -> SslAcceptor {
|
fn ssl_acceptor() -> SslAcceptor {
|
||||||
|
|
|
@ -4,8 +4,8 @@ use actix_codec::Framed;
|
||||||
use actix_http::{body::BodySize, h1, ws, Error, HttpService, Request, Response};
|
use actix_http::{body::BodySize, h1, ws, Error, HttpService, Request, Response};
|
||||||
use actix_http_test::test_server;
|
use actix_http_test::test_server;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures_util::{SinkExt, StreamExt};
|
||||||
|
|
||||||
async fn ws_service(req: ws::Frame) -> Result<ws::Message, io::Error> {
|
async fn ws_service(req: ws::Frame) -> Result<ws::Message, io::Error> {
|
||||||
match req {
|
match req {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use actix_web::{test, web, App, HttpResponse};
|
use actix_web::{test, web, App, HttpResponse};
|
||||||
use awc::Client;
|
use awc::Client;
|
||||||
use criterion::{criterion_group, criterion_main, Criterion};
|
use criterion::{criterion_group, criterion_main, Criterion};
|
||||||
use futures::future::join_all;
|
use futures_util::future::join_all;
|
||||||
|
|
||||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||||
Hello World Hello World Hello World Hello World Hello World \
|
Hello World Hello World Hello World Hello World Hello World \
|
||||||
|
|
|
@ -10,7 +10,7 @@ use actix_service::boxed::{self, BoxServiceFactory};
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
apply, apply_fn_factory, IntoServiceFactory, ServiceFactory, Transform,
|
apply, apply_fn_factory, IntoServiceFactory, ServiceFactory, Transform,
|
||||||
};
|
};
|
||||||
use futures::future::FutureExt;
|
use futures_util::future::FutureExt;
|
||||||
|
|
||||||
use crate::app_service::{AppEntry, AppInit, AppRoutingFactory};
|
use crate::app_service::{AppEntry, AppInit, AppRoutingFactory};
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
|
@ -474,7 +474,7 @@ where
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, err};
|
use futures_util::future::{ok, err};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||||
|
|
|
@ -9,7 +9,7 @@ use actix_http::{Extensions, Request, Response};
|
||||||
use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url};
|
use actix_router::{Path, ResourceDef, ResourceInfo, Router, Url};
|
||||||
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
||||||
use actix_service::{fn_service, Service, ServiceFactory};
|
use actix_service::{fn_service, Service, ServiceFactory};
|
||||||
use futures::future::{join_all, ok, FutureExt, LocalBoxFuture};
|
use futures_util::future::{join_all, ok, FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
use crate::config::{AppConfig, AppService};
|
use crate::config::{AppConfig, AppService};
|
||||||
use crate::data::{DataFactory, FnDataFactory};
|
use crate::data::{DataFactory, FnDataFactory};
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use actix_http::error::{Error, ErrorInternalServerError};
|
use actix_http::error::{Error, ErrorInternalServerError};
|
||||||
use actix_http::Extensions;
|
use actix_http::Extensions;
|
||||||
use futures::future::{err, ok, LocalBoxFuture, Ready};
|
use futures_util::future::{err, ok, LocalBoxFuture, Ready};
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::error::Error;
|
use actix_http::error::Error;
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
use crate::request::HttpRequest;
|
use crate::request::HttpRequest;
|
||||||
|
@ -50,7 +50,7 @@ pub trait FromRequest: Sized {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest};
|
/// use actix_web::{web, dev, App, Error, HttpRequest, FromRequest};
|
||||||
/// use actix_web::error::ErrorBadRequest;
|
/// use actix_web::error::ErrorBadRequest;
|
||||||
/// use futures::future::{ok, err, Ready};
|
/// use futures_util::future::{ok, err, Ready};
|
||||||
/// use serde_derive::Deserialize;
|
/// use serde_derive::Deserialize;
|
||||||
/// use rand;
|
/// use rand;
|
||||||
///
|
///
|
||||||
|
@ -122,7 +122,7 @@ where
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest};
|
/// use actix_web::{web, dev, App, Result, Error, HttpRequest, FromRequest};
|
||||||
/// use actix_web::error::ErrorBadRequest;
|
/// use actix_web::error::ErrorBadRequest;
|
||||||
/// use futures::future::{ok, err, Ready};
|
/// use futures_util::future::{ok, err, Ready};
|
||||||
/// use serde_derive::Deserialize;
|
/// use serde_derive::Deserialize;
|
||||||
/// use rand;
|
/// use rand;
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,8 +6,8 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::{Error, Response};
|
use actix_http::{Error, Response};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
use futures::ready;
|
use futures_util::ready;
|
||||||
use pin_project::pin_project;
|
use pin_project::pin_project;
|
||||||
|
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use actix_http::encoding::Encoder;
|
||||||
use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING};
|
use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING};
|
||||||
use actix_http::Error;
|
use actix_http::Error;
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
use pin_project::pin_project;
|
use pin_project::pin_project;
|
||||||
|
|
||||||
use crate::dev::BodyEncoding;
|
use crate::dev::BodyEncoding;
|
||||||
|
@ -133,7 +133,7 @@ where
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let this = self.project();
|
let this = self.project();
|
||||||
|
|
||||||
match futures::ready!(this.fut.poll(cx)) {
|
match futures_util::ready!(this.fut.poll(cx)) {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
let enc = if let Some(enc) = resp.response().get_encoding() {
|
let enc = if let Some(enc) = resp.response().get_encoding() {
|
||||||
enc
|
enc
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, Either, FutureExt, LocalBoxFuture};
|
use futures_util::future::{ok, Either, FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
/// `Middleware` for conditionally enables another middleware.
|
/// `Middleware` for conditionally enables another middleware.
|
||||||
/// The controlled middleware must not change the `Service` interfaces.
|
/// The controlled middleware must not change the `Service` interfaces.
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::rc::Rc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
|
|
||||||
use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE};
|
use crate::http::header::{HeaderName, HeaderValue, CONTENT_TYPE};
|
||||||
use crate::http::{Error as HttpError, HeaderMap};
|
use crate::http::{Error as HttpError, HeaderMap};
|
||||||
|
@ -157,7 +157,7 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::IntoService;
|
use actix_service::IntoService;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::dev::ServiceRequest;
|
use crate::dev::ServiceRequest;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::rc::Rc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use futures::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
use fxhash::FxHashMap;
|
use fxhash::FxHashMap;
|
||||||
|
|
||||||
use crate::dev::{ServiceRequest, ServiceResponse};
|
use crate::dev::{ServiceRequest, ServiceResponse};
|
||||||
|
@ -147,7 +147,7 @@ where
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::IntoService;
|
use actix_service::IntoService;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::http::{header::CONTENT_TYPE, HeaderValue, StatusCode};
|
use crate::http::{header::CONTENT_TYPE, HeaderValue, StatusCode};
|
||||||
|
|
|
@ -11,7 +11,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
@ -216,7 +216,7 @@ where
|
||||||
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let this = self.project();
|
let this = self.project();
|
||||||
|
|
||||||
let res = match futures::ready!(this.fut.poll(cx)) {
|
let res = match futures_util::ready!(this.fut.poll(cx)) {
|
||||||
Ok(res) => res,
|
Ok(res) => res,
|
||||||
Err(e) => return Poll::Ready(Err(e)),
|
Err(e) => return Poll::Ready(Err(e)),
|
||||||
};
|
};
|
||||||
|
@ -506,7 +506,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::{IntoService, Service, Transform};
|
use actix_service::{IntoService, Service, Transform};
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::http::{header, StatusCode};
|
use crate::http::{header, StatusCode};
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::task::{Context, Poll};
|
||||||
use actix_http::http::{PathAndQuery, Uri};
|
use actix_http::http::{PathAndQuery, Uri};
|
||||||
use actix_service::{Service, Transform};
|
use actix_service::{Service, Transform};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
use crate::service::{ServiceRequest, ServiceResponse};
|
use crate::service::{ServiceRequest, ServiceResponse};
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::{fmt, net};
|
||||||
use actix_http::http::{HeaderMap, Method, Uri, Version};
|
use actix_http::http::{HeaderMap, Method, Uri, Version};
|
||||||
use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead};
|
use actix_http::{Error, Extensions, HttpMessage, Message, Payload, RequestHead};
|
||||||
use actix_router::{Path, Url};
|
use actix_router::{Path, Url};
|
||||||
use futures::future::{ok, Ready};
|
use futures_util::future::{ok, Ready};
|
||||||
use tinyvec::TinyVec;
|
use tinyvec::TinyVec;
|
||||||
|
|
||||||
use crate::config::AppConfig;
|
use crate::config::AppConfig;
|
||||||
|
|
|
@ -11,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||||
};
|
};
|
||||||
use futures::future::{ok, Either, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, Either, LocalBoxFuture, Ready};
|
||||||
|
|
||||||
use crate::data::Data;
|
use crate::data::Data;
|
||||||
use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef};
|
use crate::dev::{insert_slash, AppService, HttpServiceFactory, ResourceDef};
|
||||||
|
@ -588,7 +588,7 @@ mod tests {
|
||||||
|
|
||||||
use actix_rt::time::delay_for;
|
use actix_rt::time::delay_for;
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||||
use crate::middleware::DefaultHeaders;
|
use crate::middleware::DefaultHeaders;
|
||||||
|
|
|
@ -10,8 +10,8 @@ use actix_http::http::{
|
||||||
};
|
};
|
||||||
use actix_http::{Error, Response, ResponseBuilder};
|
use actix_http::{Error, Response, ResponseBuilder};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::{err, ok, Either as EitherFuture, Ready};
|
use futures_util::future::{err, ok, Either as EitherFuture, Ready};
|
||||||
use futures::ready;
|
use futures_util::ready;
|
||||||
use pin_project::{pin_project, project};
|
use pin_project::{pin_project, project};
|
||||||
|
|
||||||
use crate::request::HttpRequest;
|
use crate::request::HttpRequest;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_http::{http::Method, Error};
|
use actix_http::{http::Method, Error};
|
||||||
use actix_service::{Service, ServiceFactory};
|
use actix_service::{Service, ServiceFactory};
|
||||||
use futures::future::{ready, FutureExt, LocalBoxFuture};
|
use futures_util::future::{ready, FutureExt, LocalBoxFuture};
|
||||||
|
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
use crate::guard::{self, Guard};
|
use crate::guard::{self, Guard};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
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};
|
||||||
|
@ -10,7 +11,7 @@ use actix_service::boxed::{self, BoxService, BoxServiceFactory};
|
||||||
use actix_service::{
|
use actix_service::{
|
||||||
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
apply, apply_fn_factory, IntoServiceFactory, Service, ServiceFactory, Transform,
|
||||||
};
|
};
|
||||||
use futures::future::{ok, Either, Future, LocalBoxFuture, Ready};
|
use futures_util::future::{ok, Either, LocalBoxFuture, Ready};
|
||||||
|
|
||||||
use crate::config::ServiceConfig;
|
use crate::config::ServiceConfig;
|
||||||
use crate::data::Data;
|
use crate::data::Data;
|
||||||
|
@ -666,7 +667,7 @@ impl ServiceFactory for ScopeEndpoint {
|
||||||
mod tests {
|
mod tests {
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
use crate::dev::{Body, ResponseBody};
|
use crate::dev::{Body, ResponseBody};
|
||||||
use crate::http::{header, HeaderValue, Method, StatusCode};
|
use crate::http::{header, HeaderValue, Method, StatusCode};
|
||||||
|
|
|
@ -6,14 +6,12 @@ use actix_http::{body::MessageBody, Error, HttpService, KeepAlive, Request, Resp
|
||||||
use actix_server::{Server, ServerBuilder};
|
use actix_server::{Server, ServerBuilder};
|
||||||
use actix_service::{map_config, IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{map_config, IntoServiceFactory, Service, ServiceFactory};
|
||||||
|
|
||||||
use net2::TcpBuilder;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use actix_http::Protocol;
|
use actix_http::Protocol;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use actix_service::pipeline_factory;
|
use actix_service::pipeline_factory;
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
||||||
|
@ -562,13 +560,16 @@ fn create_tcp_listener(
|
||||||
addr: net::SocketAddr,
|
addr: net::SocketAddr,
|
||||||
backlog: i32,
|
backlog: i32,
|
||||||
) -> io::Result<net::TcpListener> {
|
) -> io::Result<net::TcpListener> {
|
||||||
let builder = match addr {
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
net::SocketAddr::V4(_) => TcpBuilder::new_v4()?,
|
let domain = match addr {
|
||||||
net::SocketAddr::V6(_) => TcpBuilder::new_v6()?,
|
net::SocketAddr::V4(_) => Domain::ipv4(),
|
||||||
|
net::SocketAddr::V6(_) => Domain::ipv6(),
|
||||||
};
|
};
|
||||||
builder.reuse_address(true)?;
|
let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
|
||||||
builder.bind(addr)?;
|
socket.set_reuse_address(true)?;
|
||||||
Ok(builder.listen(backlog)?)
|
socket.bind(&addr.into())?;
|
||||||
|
socket.listen(backlog)?;
|
||||||
|
Ok(socket.into_tcp_listener())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
|
|
|
@ -536,7 +536,7 @@ mod tests {
|
||||||
use crate::test::{init_service, TestRequest};
|
use crate::test::{init_service, TestRequest};
|
||||||
use crate::{guard, http, web, App, HttpResponse};
|
use crate::{guard, http, web, App, HttpResponse};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use futures::future::ok;
|
use futures_util::future::ok;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_service_request() {
|
fn test_service_request() {
|
||||||
|
|
15
src/test.rs
15
src/test.rs
|
@ -18,12 +18,13 @@ use actix_service::{
|
||||||
use awc::error::PayloadError;
|
use awc::error::PayloadError;
|
||||||
use awc::{Client, ClientRequest, ClientResponse, Connector};
|
use awc::{Client, ClientRequest, ClientResponse, Connector};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use futures::future::ok;
|
use futures_core::Stream;
|
||||||
use futures::stream::{Stream, StreamExt};
|
use futures_util::future::ok;
|
||||||
use net2::TcpBuilder;
|
use futures_util::StreamExt;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
pub use actix_http::test::TestBuffer;
|
pub use actix_http::test::TestBuffer;
|
||||||
|
|
||||||
|
@ -912,10 +913,10 @@ impl TestServerConfig {
|
||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = TcpBuilder::new_v4().unwrap();
|
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
||||||
socket.bind(&addr).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.to_tcp_listener().unwrap();
|
let tcp = socket.into_tcp_listener();
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,8 @@ use std::{fmt, ops};
|
||||||
use actix_http::{Error, HttpMessage, Payload, Response};
|
use actix_http::{Error, HttpMessage, Payload, Response};
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use encoding_rs::{Encoding, UTF_8};
|
use encoding_rs::{Encoding, UTF_8};
|
||||||
use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
use futures::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ use std::task::{Context, Poll};
|
||||||
use std::{fmt, ops};
|
use std::{fmt, ops};
|
||||||
|
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
use futures_util::future::{err, ok, FutureExt, LocalBoxFuture, Ready};
|
||||||
use futures::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::{fmt, ops};
|
||||||
|
|
||||||
use actix_http::error::{Error, ErrorNotFound};
|
use actix_http::error::{Error, ErrorNotFound};
|
||||||
use actix_router::PathDeserializer;
|
use actix_router::PathDeserializer;
|
||||||
use futures::future::{ready, Ready};
|
use futures_util::future::{ready, Ready};
|
||||||
use serde::de;
|
use serde::de;
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
|
|
|
@ -8,8 +8,9 @@ use actix_http::error::{Error, ErrorBadRequest, PayloadError};
|
||||||
use actix_http::HttpMessage;
|
use actix_http::HttpMessage;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use encoding_rs::UTF_8;
|
use encoding_rs::UTF_8;
|
||||||
use futures::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready};
|
use futures_core::stream::Stream;
|
||||||
use futures::{Stream, StreamExt};
|
use futures_util::future::{err, ok, Either, FutureExt, LocalBoxFuture, Ready};
|
||||||
|
use futures_util::StreamExt;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|
||||||
use crate::dev;
|
use crate::dev;
|
||||||
|
@ -22,9 +23,10 @@ use crate::request::HttpRequest;
|
||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use futures::{Future, Stream, StreamExt};
|
|
||||||
/// use actix_web::{web, error, App, Error, HttpResponse};
|
/// use actix_web::{web, error, App, Error, HttpResponse};
|
||||||
///
|
/// use std::future::Future;
|
||||||
|
/// use futures_core::stream::Stream;
|
||||||
|
/// use futures_util::StreamExt;
|
||||||
/// /// extract binary data from request
|
/// /// extract binary data from request
|
||||||
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
||||||
/// {
|
/// {
|
||||||
|
@ -70,8 +72,10 @@ impl Stream for Payload {
|
||||||
/// ## Example
|
/// ## Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use futures::{Future, Stream, StreamExt};
|
|
||||||
/// use actix_web::{web, error, App, Error, HttpResponse};
|
/// use actix_web::{web, error, App, Error, HttpResponse};
|
||||||
|
/// use std::future::Future;
|
||||||
|
/// use futures_core::stream::Stream;
|
||||||
|
/// use futures_util::StreamExt;
|
||||||
///
|
///
|
||||||
/// /// extract binary data from request
|
/// /// extract binary data from request
|
||||||
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
/// async fn index(mut body: web::Payload) -> Result<HttpResponse, Error>
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::sync::Arc;
|
||||||
use std::{fmt, ops};
|
use std::{fmt, ops};
|
||||||
|
|
||||||
use actix_http::error::Error;
|
use actix_http::error::Error;
|
||||||
use futures::future::{err, ok, Ready};
|
use futures_util::future::{err, ok, Ready};
|
||||||
use serde::de;
|
use serde::de;
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use encoding_rs::{Encoding, UTF_8};
|
use encoding_rs::{Encoding, UTF_8};
|
||||||
use futures::Stream;
|
use futures_util::stream::Stream;
|
||||||
|
|
||||||
use crate::dev::Payload;
|
use crate::dev::Payload;
|
||||||
use crate::error::{PayloadError, ReadlinesError};
|
use crate::error::{PayloadError, ReadlinesError};
|
||||||
|
@ -172,7 +172,7 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use futures::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::TestRequest;
|
use crate::test::TestRequest;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
//! Essentials helper functions and types for application registration.
|
//! Essentials helper functions and types for application registration.
|
||||||
use actix_http::http::Method;
|
use actix_http::http::Method;
|
||||||
use actix_router::IntoPattern;
|
use actix_router::IntoPattern;
|
||||||
use futures::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
pub use actix_http::Response as HttpResponse;
|
pub use actix_http::Response as HttpResponse;
|
||||||
pub use bytes::{Bytes, BytesMut};
|
pub use bytes::{Bytes, BytesMut};
|
||||||
pub use futures::channel::oneshot::Canceled;
|
pub use futures_channel::oneshot::Canceled;
|
||||||
|
|
||||||
use crate::error::BlockingError;
|
use crate::error::BlockingError;
|
||||||
use crate::extract::FromRequest;
|
use crate::extract::FromRequest;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Update `actix-connect` dependency to 2.0.0-alpha.2
|
* Update `actix-connect` dependency to 2.0.0-alpha.2
|
||||||
* Make `test_server` `async` fn.
|
* Make `test_server` `async` fn.
|
||||||
* Bump minimum supported Rust version to 1.40
|
* Bump minimum supported Rust version to 1.40
|
||||||
|
* Replace deprecated `net2` crate with `socket2`
|
||||||
|
|
||||||
## [1.0.0] - 2019-12-13
|
## [1.0.0] - 2019-12-13
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,11 @@ awc = "2.0.0-alpha.1"
|
||||||
|
|
||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
futures = "0.3.1"
|
futures-core = { version = "0.3.5", default-features = false }
|
||||||
http = "0.2.0"
|
http = "0.2.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
net2 = "0.2"
|
socket2 = "0.3"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
sha1 = "0.6"
|
sha1 = "0.6"
|
||||||
|
|
|
@ -7,9 +7,9 @@ use actix_rt::{net::TcpStream, System};
|
||||||
use actix_server::{Server, ServiceFactory};
|
use actix_server::{Server, ServiceFactory};
|
||||||
use awc::{error::PayloadError, ws, Client, ClientRequest, ClientResponse, Connector};
|
use awc::{error::PayloadError, ws, Client, ClientRequest, ClientResponse, Connector};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures_core::stream::Stream;
|
||||||
use http::Method;
|
use http::Method;
|
||||||
use net2::TcpBuilder;
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
pub use actix_testing::*;
|
pub use actix_testing::*;
|
||||||
|
|
||||||
|
@ -104,10 +104,10 @@ pub async fn test_server<F: ServiceFactory<TcpStream>>(factory: F) -> TestServer
|
||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = TcpBuilder::new_v4().unwrap();
|
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
||||||
socket.bind(&addr).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.to_tcp_listener().unwrap();
|
let tcp = socket.into_tcp_listener();
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,25 +1,15 @@
|
||||||
use net2::TcpBuilder;
|
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::{net, thread, time::Duration};
|
use std::{thread, time::Duration};
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use open_ssl::ssl::SslAcceptorBuilder;
|
use open_ssl::ssl::SslAcceptorBuilder;
|
||||||
|
|
||||||
use actix_web::{web, App, HttpResponse, HttpServer};
|
use actix_web::{test, web, App, HttpResponse, HttpServer};
|
||||||
|
|
||||||
fn unused_addr() -> net::SocketAddr {
|
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
|
||||||
let socket = TcpBuilder::new_v4().unwrap();
|
|
||||||
socket.bind(&addr).unwrap();
|
|
||||||
socket.reuse_address(true).unwrap();
|
|
||||||
let tcp = socket.to_tcp_listener().unwrap();
|
|
||||||
tcp.local_addr().unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn test_start() {
|
async fn test_start() {
|
||||||
let addr = unused_addr();
|
let addr = test::unused_addr();
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
@ -92,7 +82,7 @@ fn ssl_acceptor() -> std::io::Result<SslAcceptorBuilder> {
|
||||||
async fn test_start_ssl() {
|
async fn test_start_ssl() {
|
||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
|
|
||||||
let addr = unused_addr();
|
let addr = test::unused_addr();
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use std::future::Future;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
@ -11,7 +12,7 @@ use bytes::Bytes;
|
||||||
use flate2::read::GzDecoder;
|
use flate2::read::GzDecoder;
|
||||||
use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder};
|
use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder};
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
use futures::{ready, Future};
|
use futures_util::ready;
|
||||||
use rand::{distributions::Alphanumeric, Rng};
|
use rand::{distributions::Alphanumeric, Rng};
|
||||||
|
|
||||||
use actix_web::dev::BodyEncoding;
|
use actix_web::dev::BodyEncoding;
|
||||||
|
@ -56,7 +57,7 @@ impl TestBody {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl futures::Stream for TestBody {
|
impl futures_core::stream::Stream for TestBody {
|
||||||
type Item = Result<Bytes, Error>;
|
type Item = Result<Bytes, Error>;
|
||||||
|
|
||||||
fn poll_next(
|
fn poll_next(
|
||||||
|
@ -349,7 +350,7 @@ async fn test_body_br_streaming() {
|
||||||
async fn test_head_binary() {
|
async fn test_head_binary() {
|
||||||
let srv = test::start_with(test::config().h1(), || {
|
let srv = test::start_with(test::config().h1(), || {
|
||||||
App::new().service(web::resource("/").route(
|
App::new().service(web::resource("/").route(
|
||||||
web::head().to(move || HttpResponse::Ok().content_length(100).body(STR)),
|
web::head().to(move || HttpResponse::Ok().body(STR)),
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -371,8 +372,7 @@ async fn test_no_chunking() {
|
||||||
let srv = test::start_with(test::config().h1(), || {
|
let srv = test::start_with(test::config().h1(), || {
|
||||||
App::new().service(web::resource("/").route(web::to(move || {
|
App::new().service(web::resource("/").route(web::to(move || {
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.no_chunking()
|
.no_chunking(STR.len() as u64)
|
||||||
.content_length(STR.len() as u64)
|
|
||||||
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
|
.streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24))
|
||||||
})))
|
})))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue