1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-09-03 01:56:38 +02:00

apply standard formatting

This commit is contained in:
Rob Ede
2023-07-17 02:38:12 +01:00
parent 60c76c5e10
commit 79a38e0628
138 changed files with 916 additions and 1180 deletions

View File

@@ -7,19 +7,15 @@ use std::{
};
use actix_codec::{AsyncRead, AsyncWrite, Framed, ReadBuf};
use actix_http::{body::MessageBody, h1::ClientCodec, Payload, RequestHeadType, ResponseHead};
use actix_rt::task::JoinHandle;
use bytes::Bytes;
use futures_core::future::LocalBoxFuture;
use h2::client::SendRequest;
use actix_http::{body::MessageBody, h1::ClientCodec, Payload, RequestHeadType, ResponseHead};
use super::{error::SendRequestError, h1proto, h2proto, pool::Acquired};
use crate::BoxError;
use super::error::SendRequestError;
use super::pool::Acquired;
use super::{h1proto, h2proto};
/// Trait alias for types impl [tokio::io::AsyncRead] and [tokio::io::AsyncWrite].
pub trait ConnectionIo: AsyncRead + AsyncWrite + Unpin + 'static {}
@@ -83,10 +79,7 @@ impl<Io: ConnectionIo> AsyncWrite for H1Connection<Io> {
self.io_pin_mut().poll_flush(cx)
}
fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), io::Error>> {
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
self.io_pin_mut().poll_shutdown(cx)
}

View File

@@ -133,11 +133,8 @@ impl<S> Connector<S> {
pub fn connector<S1, Io1>(self, connector: S1) -> Connector<S1>
where
Io1: ActixStream + fmt::Debug + 'static,
S1: Service<
ConnectInfo<Uri>,
Response = TcpConnection<Uri, Io1>,
Error = TcpConnectError,
> + Clone,
S1: Service<ConnectInfo<Uri>, Response = TcpConnection<Uri, Io1>, Error = TcpConnectError>
+ Clone,
{
Connector {
connector,
@@ -189,10 +186,7 @@ where
#[doc(hidden)]
#[cfg(feature = "openssl")]
#[deprecated(since = "3.0.0", note = "Renamed to `Connector::openssl`.")]
pub fn ssl(
mut self,
connector: actix_tls::connect::openssl::reexports::SslConnector,
) -> Self {
pub fn ssl(mut self, connector: actix_tls::connect::openssl::reexports::SslConnector) -> Self {
self.tls = OurTlsConnector::Openssl(connector);
self
}
@@ -312,9 +306,7 @@ where
let tls = match self.tls {
#[cfg(feature = "openssl")]
OurTlsConnector::OpensslBuilder(builder) => {
OurTlsConnector::Openssl(builder.build())
}
OurTlsConnector::OpensslBuilder(builder) => OurTlsConnector::Openssl(builder.build()),
tls => tls,
};
@@ -467,9 +459,7 @@ pub struct TcpConnectorService<S: Clone> {
impl<S, Io> Service<Connect> for TcpConnectorService<S>
where
S: Service<Connect, Response = TcpConnection<Uri, Io>, Error = ConnectError>
+ Clone
+ 'static,
S: Service<Connect, Response = TcpConnection<Uri, Io>, Error = ConnectError> + Clone + 'static,
{
type Response = (Io, Protocol);
type Error = ConnectError;
@@ -520,9 +510,8 @@ struct TlsConnectorService<Tcp, Tls> {
impl<Tcp, Tls, IO> Service<Connect> for TlsConnectorService<Tcp, Tls>
where
Tcp: Service<Connect, Response = TcpConnection<Uri, IO>, Error = ConnectError>
+ Clone
+ 'static,
Tcp:
Service<Connect, Response = TcpConnection<Uri, IO>, Error = ConnectError> + Clone + 'static,
Tls: Service<TcpConnection<Uri, IO>, Error = std::io::Error> + Clone + 'static,
Tls::Response: IntoConnectionIo,
IO: ConnectionIo,

View File

@@ -1,11 +1,9 @@
use std::{fmt, io};
use derive_more::{Display, From};
use actix_http::error::{HttpError, ParseError};
#[cfg(feature = "openssl")]
use actix_tls::accept::openssl::reexports::Error as OpensslError;
use derive_more::{Display, From};
use crate::BoxError;

View File

@@ -18,12 +18,11 @@ use futures_core::{ready, Stream};
use futures_util::SinkExt as _;
use pin_project_lite::pin_project;
use crate::BoxError;
use super::{
connection::{ConnectionIo, H1Connection},
error::{ConnectError, SendRequestError},
};
use crate::BoxError;
pub(crate) async fn send_request<Io, B>(
io: H1Connection<Io>,

View File

@@ -1,28 +1,29 @@
use std::future::Future;
use actix_utils::future::poll_fn;
use bytes::Bytes;
use h2::{
client::{Builder, Connection, SendRequest},
SendStream,
};
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
use http::{request::Request, Method, Version};
use log::trace;
use actix_http::{
body::{BodySize, MessageBody},
header::HeaderMap,
Payload, RequestHeadType, ResponseHead,
};
use crate::BoxError;
use actix_utils::future::poll_fn;
use bytes::Bytes;
use h2::{
client::{Builder, Connection, SendRequest},
SendStream,
};
use http::{
header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING},
request::Request,
Method, Version,
};
use log::trace;
use super::{
config::ConnectorConfig,
connection::{ConnectionIo, H2Connection},
error::SendRequestError,
};
use crate::BoxError;
pub(crate) async fn send_request<Io, B>(
mut io: H2Connection<Io>,

View File

@@ -19,9 +19,11 @@ mod h1proto;
mod h2proto;
mod pool;
pub use self::connection::{Connection, ConnectionIo};
pub use self::connector::{Connector, ConnectorService};
pub use self::error::{ConnectError, FreezeRequestError, InvalidUrl, SendRequestError};
pub use self::{
connection::{Connection, ConnectionIo},
connector::{Connector, ConnectorService},
error::{ConnectError, FreezeRequestError, InvalidUrl, SendRequestError},
};
#[derive(Clone)]
pub struct Connect {

View File

@@ -23,11 +23,13 @@ use http::uri::Authority;
use pin_project_lite::pin_project;
use tokio::sync::{OwnedSemaphorePermit, Semaphore};
use super::config::ConnectorConfig;
use super::connection::{ConnectionInnerType, ConnectionIo, ConnectionType, H2ConnectionInner};
use super::error::ConnectError;
use super::h2proto::handshake;
use super::Connect;
use super::{
config::ConnectorConfig,
connection::{ConnectionInnerType, ConnectionIo, ConnectionType, H2ConnectionInner},
error::ConnectError,
h2proto::handshake,
Connect,
};
#[derive(Hash, Eq, PartialEq, Clone, Debug)]
pub struct Key {
@@ -201,7 +203,9 @@ where
// check if the connection is still usable
if let ConnectionInnerType::H1(ref mut io) = c.conn {
let check = ConnectionCheckFuture { io };
match check.now_or_never().expect("ConnectionCheckFuture must never yield with Poll::Pending.") {
match check.now_or_never().expect(
"ConnectionCheckFuture must never yield with Poll::Pending.",
) {
ConnectionState::Tainted => {
inner.close(c.conn);
continue;