mirror of https://github.com/fafhrd91/actix-web
Merge branch 'master' into refactor/connection_trait
This commit is contained in:
commit
3f080e6103
|
@ -4,7 +4,12 @@
|
||||||
### Changed
|
### Changed
|
||||||
* Feature `cookies` is now optional and disabled by default. [#1981]
|
* Feature `cookies` is now optional and disabled by default. [#1981]
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
* re-export of `futures_channel::oneshot::Canceled` is removed from `error` mod. [#1994]
|
||||||
|
* `ResponseError` impl for `futures_channel::oneshot::Canceled` is removed. [#1994]
|
||||||
|
|
||||||
[#1981]: https://github.com/actix/actix-web/pull/1981
|
[#1981]: https://github.com/actix/actix-web/pull/1981
|
||||||
|
[#1994]: https://github.com/actix/actix-web/pull/1994
|
||||||
|
|
||||||
|
|
||||||
## 3.0.0-beta.3 - 2021-02-10
|
## 3.0.0-beta.3 - 2021-02-10
|
||||||
|
|
|
@ -59,13 +59,11 @@ cfg-if = "1"
|
||||||
cookie = { version = "0.14.1", features = ["percent-encode"], optional = true }
|
cookie = { version = "0.14.1", features = ["percent-encode"], optional = true }
|
||||||
derive_more = "0.99.5"
|
derive_more = "0.99.5"
|
||||||
encoding_rs = "0.8"
|
encoding_rs = "0.8"
|
||||||
futures-channel = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
|
||||||
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
futures-core = { version = "0.3.7", default-features = false, features = ["alloc"] }
|
||||||
futures-util = { version = "0.3.7", default-features = false, features = ["alloc", "sink"] }
|
futures-util = { version = "0.3.7", default-features = false, features = ["alloc", "sink"] }
|
||||||
h2 = "0.3.0"
|
h2 = "0.3.0"
|
||||||
http = "0.2.2"
|
http = "0.2.2"
|
||||||
httparse = "1.3"
|
httparse = "1.3"
|
||||||
indexmap = "1.3"
|
|
||||||
itoa = "0.4"
|
itoa = "0.4"
|
||||||
language-tags = "0.2"
|
language-tags = "0.2"
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
|
@ -79,9 +77,9 @@ serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_urlencoded = "0.7"
|
serde_urlencoded = "0.7"
|
||||||
sha-1 = "0.9"
|
sha-1 = "0.9"
|
||||||
slab = "0.4"
|
|
||||||
smallvec = "1.6"
|
smallvec = "1.6"
|
||||||
time = { version = "0.2.23", default-features = false, features = ["std"] }
|
time = { version = "0.2.23", default-features = false, features = ["std"] }
|
||||||
|
tokio = { version = "1.2", features = ["sync"] }
|
||||||
|
|
||||||
# compression
|
# compression
|
||||||
brotli2 = { version="0.3.2", optional = true }
|
brotli2 = { version="0.3.2", optional = true }
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Traits and structures to aid consuming and writing HTTP payloads.
|
//! Traits and structures to aid consuming and writing HTTP payloads.
|
||||||
|
|
||||||
|
#[allow(clippy::module_inception)]
|
||||||
mod body;
|
mod body;
|
||||||
mod body_stream;
|
mod body_stream;
|
||||||
mod message_body;
|
mod message_body;
|
||||||
|
|
|
@ -24,9 +24,10 @@ pub(crate) enum ConnectionType<Io> {
|
||||||
H2(H2Connection),
|
H2(H2Connection),
|
||||||
}
|
}
|
||||||
|
|
||||||
// h2 connection has two parts: SendRequest and Connection.
|
/// `H2Connection` has two parts: `SendRequest` and `Connection`.
|
||||||
// Connection is spawned as async task on runtime and H2Connection would hold a handle for
|
///
|
||||||
// this task. So it can wake up and quit the task when SendRequest is dropped.
|
/// `Connection` is spawned as an async task on runtime and `H2Connection` holds a handle for
|
||||||
|
/// this task. Therefore, it can wake up and quit the task when SendRequest is dropped.
|
||||||
pub(crate) struct H2Connection {
|
pub(crate) struct H2Connection {
|
||||||
handle: JoinHandle<()>,
|
handle: JoinHandle<()>,
|
||||||
sender: SendRequest<Bytes>,
|
sender: SendRequest<Bytes>,
|
||||||
|
@ -102,7 +103,10 @@ pub(crate) trait ConnectionLifetime: AsyncRead + AsyncWrite + 'static {
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// HTTP client connection
|
/// HTTP client connection
|
||||||
pub struct IoConnection<T> {
|
pub struct IoConnection<T>
|
||||||
|
where
|
||||||
|
T: AsyncWrite + Unpin + 'static,
|
||||||
|
{
|
||||||
io: Option<ConnectionType<T>>,
|
io: Option<ConnectionType<T>>,
|
||||||
created: time::Instant,
|
created: time::Instant,
|
||||||
pool: Option<Acquired<T>>,
|
pool: Option<Acquired<T>>,
|
||||||
|
@ -110,7 +114,7 @@ pub struct IoConnection<T> {
|
||||||
|
|
||||||
impl<T> fmt::Debug for IoConnection<T>
|
impl<T> fmt::Debug for IoConnection<T>
|
||||||
where
|
where
|
||||||
T: fmt::Debug,
|
T: AsyncWrite + Unpin + fmt::Debug + 'static,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self.io {
|
match self.io {
|
||||||
|
@ -137,6 +141,11 @@ impl<T: AsyncRead + AsyncWrite + Unpin> IoConnection<T> {
|
||||||
pub(crate) fn into_inner(self) -> (ConnectionType<T>, time::Instant) {
|
pub(crate) fn into_inner(self) -> (ConnectionType<T>, time::Instant) {
|
||||||
(self.io.unwrap(), self.created)
|
(self.io.unwrap(), self.created)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) fn into_parts(self) -> (ConnectionType<T>, time::Instant, Acquired<T>) {
|
||||||
|
(self.io.unwrap(), self.created, self.pool.unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Connection for IoConnection<T>
|
impl<T> Connection for IoConnection<T>
|
||||||
|
@ -201,7 +210,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub(crate) enum EitherConnection<A, B> {
|
pub(crate) enum EitherConnection<A, B>
|
||||||
|
where
|
||||||
|
A: AsyncRead + AsyncWrite + Unpin + 'static,
|
||||||
|
B: AsyncRead + AsyncWrite + Unpin + 'static,
|
||||||
|
{
|
||||||
A(IoConnection<A>),
|
A(IoConnection<A>),
|
||||||
B(IoConnection<B>),
|
B(IoConnection<B>),
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub enum ConnectError {
|
||||||
Resolver(Box<dyn std::error::Error>),
|
Resolver(Box<dyn std::error::Error>),
|
||||||
|
|
||||||
/// No dns records
|
/// No dns records
|
||||||
#[display(fmt = "No dns records found for the input")]
|
#[display(fmt = "No DNS records found for the input")]
|
||||||
NoRecords,
|
NoRecords,
|
||||||
|
|
||||||
/// Http2 error
|
/// Http2 error
|
||||||
|
|
|
@ -165,7 +165,10 @@ where
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// HTTP client connection
|
/// HTTP client connection
|
||||||
pub struct H1Connection<T> {
|
pub struct H1Connection<T>
|
||||||
|
where
|
||||||
|
T: AsyncWrite + Unpin + 'static,
|
||||||
|
{
|
||||||
/// T should be `Unpin`
|
/// T should be `Unpin`
|
||||||
io: Option<T>,
|
io: Option<T>,
|
||||||
created: time::Instant,
|
created: time::Instant,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,7 +11,6 @@ use actix_utils::dispatcher::DispatcherError as FramedDispatcherError;
|
||||||
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;
|
|
||||||
use http::uri::InvalidUri;
|
use http::uri::InvalidUri;
|
||||||
use http::{header, Error as HttpError, StatusCode};
|
use http::{header, Error as HttpError, StatusCode};
|
||||||
use serde::de::value::Error as DeError;
|
use serde::de::value::Error as DeError;
|
||||||
|
@ -186,9 +185,6 @@ impl ResponseError for DeError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns [`StatusCode::INTERNAL_SERVER_ERROR`] for [`Canceled`].
|
|
||||||
impl ResponseError for Canceled {}
|
|
||||||
|
|
||||||
/// Returns [`StatusCode::BAD_REQUEST`] for [`Utf8Error`].
|
/// Returns [`StatusCode::BAD_REQUEST`] for [`Utf8Error`].
|
||||||
impl ResponseError for Utf8Error {
|
impl ResponseError for Utf8Error {
|
||||||
fn status_code(&self) -> StatusCode {
|
fn status_code(&self) -> StatusCode {
|
||||||
|
|
Loading…
Reference in New Issue