mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
improve code readability
This commit is contained in:
parent
e1683313ec
commit
21f6c9d7a5
@ -176,7 +176,7 @@ mod _original {
|
|||||||
buf[5] = b'0';
|
buf[5] = b'0';
|
||||||
buf[7] = b'9';
|
buf[7] = b'9';
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut curr: isize = 12;
|
let mut curr: isize = 12;
|
||||||
|
@ -371,7 +371,7 @@ impl MessageBody for String {
|
|||||||
pub struct BodyStream<S: Unpin, E> {
|
pub struct BodyStream<S: Unpin, E> {
|
||||||
#[pin]
|
#[pin]
|
||||||
stream: S,
|
stream: S,
|
||||||
_t: PhantomData<E>,
|
_phantom: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, E> BodyStream<S, E>
|
impl<S, E> BodyStream<S, E>
|
||||||
@ -382,7 +382,7 @@ where
|
|||||||
pub fn new(stream: S) -> Self {
|
pub fn new(stream: S) -> Self {
|
||||||
BodyStream {
|
BodyStream {
|
||||||
stream,
|
stream,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ pub struct HttpServiceBuilder<T, S, X = ExpectHandler, U = UpgradeHandler> {
|
|||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<S>,
|
_phantom: PhantomData<S>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler>
|
impl<T, S> HttpServiceBuilder<T, S, ExpectHandler, UpgradeHandler>
|
||||||
@ -49,7 +49,7 @@ where
|
|||||||
expect: ExpectHandler,
|
expect: ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ where
|
|||||||
expect: expect.into_factory(),
|
expect: expect.into_factory(),
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ where
|
|||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
upgrade: Some(upgrade.into_factory()),
|
upgrade: Some(upgrade.into_factory()),
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ pub struct Connector<T, U> {
|
|||||||
config: ConnectorConfig,
|
config: ConnectorConfig,
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
ssl: SslConnector,
|
ssl: SslConnector,
|
||||||
_t: PhantomData<U>,
|
_phantom: PhantomData<U>,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Io: AsyncRead + AsyncWrite + Unpin {}
|
trait Io: AsyncRead + AsyncWrite + Unpin {}
|
||||||
@ -72,7 +72,7 @@ impl Connector<(), ()> {
|
|||||||
ssl: Self::build_ssl(vec![b"h2".to_vec(), b"http/1.1".to_vec()]),
|
ssl: Self::build_ssl(vec![b"h2".to_vec(), b"http/1.1".to_vec()]),
|
||||||
connector: default_connector(),
|
connector: default_connector(),
|
||||||
config: ConnectorConfig::default(),
|
config: ConnectorConfig::default(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ impl<T, U> Connector<T, U> {
|
|||||||
connector,
|
connector,
|
||||||
config: self.config,
|
config: self.config,
|
||||||
ssl: self.ssl,
|
ssl: self.ssl,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,11 +468,11 @@ mod connect_impl {
|
|||||||
match req.uri.scheme_str() {
|
match req.uri.scheme_str() {
|
||||||
Some("https") | Some("wss") => Either::Right(InnerConnectorResponseB {
|
Some("https") | Some("wss") => Either::Right(InnerConnectorResponseB {
|
||||||
fut: self.ssl_pool.call(req),
|
fut: self.ssl_pool.call(req),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}),
|
}),
|
||||||
_ => Either::Left(InnerConnectorResponseA {
|
_ => Either::Left(InnerConnectorResponseA {
|
||||||
fut: self.tcp_pool.call(req),
|
fut: self.tcp_pool.call(req),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -486,7 +486,7 @@ mod connect_impl {
|
|||||||
{
|
{
|
||||||
#[pin]
|
#[pin]
|
||||||
fut: <ConnectionPool<T, Io1> as Service<Connect>>::Future,
|
fut: <ConnectionPool<T, Io1> as Service<Connect>>::Future,
|
||||||
_t: PhantomData<Io2>,
|
_phantom: PhantomData<Io2>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Io1, Io2> Future for InnerConnectorResponseA<T, Io1, Io2>
|
impl<T, Io1, Io2> Future for InnerConnectorResponseA<T, Io1, Io2>
|
||||||
@ -513,7 +513,7 @@ mod connect_impl {
|
|||||||
{
|
{
|
||||||
#[pin]
|
#[pin]
|
||||||
fut: <ConnectionPool<T, Io2> as Service<Connect>>::Future,
|
fut: <ConnectionPool<T, Io2> as Service<Connect>>::Future,
|
||||||
_t: PhantomData<Io1>,
|
_phantom: PhantomData<Io1>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, Io1, Io2> Future for InnerConnectorResponseB<T, Io1, Io2>
|
impl<T, Io1, Io2> Future for InnerConnectorResponseB<T, Io1, Io2>
|
||||||
|
@ -72,7 +72,7 @@ where
|
|||||||
|
|
||||||
// send request body
|
// send request body
|
||||||
match body.size() {
|
match body.size() {
|
||||||
BodySize::None | BodySize::Empty | BodySize::Sized(0) => (),
|
BodySize::None | BodySize::Empty | BodySize::Sized(0) => {},
|
||||||
_ => send_body(body, Pin::new(&mut framed_inner)).await?,
|
_ => send_body(body, Pin::new(&mut framed_inner)).await?,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ where
|
|||||||
CONNECTION | TRANSFER_ENCODING => continue, // http2 specific
|
CONNECTION | TRANSFER_ENCODING => continue, // http2 specific
|
||||||
CONTENT_LENGTH if skip_len => continue,
|
CONTENT_LENGTH if skip_len => continue,
|
||||||
// DATE => has_date = true,
|
// DATE => has_date = true,
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
req.headers_mut().append(key, value.clone());
|
req.headers_mut().append(key, value.clone());
|
||||||
}
|
}
|
||||||
|
@ -334,7 +334,7 @@ where
|
|||||||
let mut read_buf = ReadBuf::new(&mut buf);
|
let mut read_buf = ReadBuf::new(&mut buf);
|
||||||
if let ConnectionType::H1(ref mut s) = io {
|
if let ConnectionType::H1(ref mut s) = io {
|
||||||
match Pin::new(s).poll_read(cx, &mut read_buf) {
|
match Pin::new(s).poll_read(cx, &mut read_buf) {
|
||||||
Poll::Pending => (),
|
Poll::Pending => {},
|
||||||
Poll::Ready(Ok(())) if !read_buf.filled().is_empty() => {
|
Poll::Ready(Ok(())) if !read_buf.filled().is_empty() => {
|
||||||
if let Some(timeout) = self.config.disconnect_timeout {
|
if let Some(timeout) = self.config.disconnect_timeout {
|
||||||
if let ConnectionType::H1(io) = io {
|
if let ConnectionType::H1(io) = io {
|
||||||
|
@ -137,7 +137,7 @@ pub(crate) trait MessageType: Sized {
|
|||||||
expect = true;
|
expect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
headers.append(name, value);
|
headers.append(name, value);
|
||||||
@ -685,7 +685,7 @@ mod tests {
|
|||||||
match MessageDecoder::<Request>::default().decode($e) {
|
match MessageDecoder::<Request>::default().decode($e) {
|
||||||
Err(err) => match err {
|
Err(err) => match err {
|
||||||
ParseError::Io(_) => unreachable!("Parse error expected"),
|
ParseError::Io(_) => unreachable!("Parse error expected"),
|
||||||
_ => (),
|
_ => {},
|
||||||
},
|
},
|
||||||
_ => unreachable!("Error expected"),
|
_ => unreachable!("Error expected"),
|
||||||
}
|
}
|
||||||
|
@ -736,7 +736,7 @@ where
|
|||||||
let _ = this.ka_timer.as_mut().as_pin_mut().unwrap().poll(cx);
|
let _ = this.ka_timer.as_mut().as_pin_mut().unwrap().poll(cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Poll::Pending => (),
|
Poll::Pending => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -21,7 +21,7 @@ const AVERAGE_HEADER_SIZE: usize = 30;
|
|||||||
pub(crate) struct MessageEncoder<T: MessageType> {
|
pub(crate) struct MessageEncoder<T: MessageType> {
|
||||||
pub length: BodySize,
|
pub length: BodySize,
|
||||||
pub te: TransferEncoding,
|
pub te: TransferEncoding,
|
||||||
_t: PhantomData<T>,
|
_phantom: PhantomData<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: MessageType> Default for MessageEncoder<T> {
|
impl<T: MessageType> Default for MessageEncoder<T> {
|
||||||
@ -29,7 +29,7 @@ impl<T: MessageType> Default for MessageEncoder<T> {
|
|||||||
MessageEncoder {
|
MessageEncoder {
|
||||||
length: BodySize::None,
|
length: BodySize::None,
|
||||||
te: TransferEncoding::empty(),
|
te: TransferEncoding::empty(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ pub(crate) trait MessageType: Sized {
|
|||||||
dst.put_slice(b"connection: close\r\n")
|
dst.put_slice(b"connection: close\r\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// merging headers from head and extra headers. HeaderMap::new() does not allocate.
|
// merging headers from head and extra headers. HeaderMap::new() does not allocate.
|
||||||
@ -148,7 +148,7 @@ pub(crate) trait MessageType: Sized {
|
|||||||
CONNECTION => continue,
|
CONNECTION => continue,
|
||||||
TRANSFER_ENCODING | CONTENT_LENGTH if skip_len => continue,
|
TRANSFER_ENCODING | CONTENT_LENGTH if skip_len => continue,
|
||||||
DATE => has_date = true,
|
DATE => has_date = true,
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
let k = key.as_str().as_bytes();
|
let k = key.as_str().as_bytes();
|
||||||
|
@ -30,7 +30,7 @@ pub struct H1Service<T, S, B, X = ExpectHandler, U = UpgradeHandler> {
|
|||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> H1Service<T, S, B>
|
impl<T, S, B> H1Service<T, S, B>
|
||||||
@ -52,7 +52,7 @@ where
|
|||||||
expect: ExpectHandler,
|
expect: ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ where
|
|||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ where
|
|||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ where
|
|||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
cfg: Some(self.cfg.clone()),
|
cfg: Some(self.cfg.clone()),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +299,7 @@ where
|
|||||||
upgrade: Option<U::Service>,
|
upgrade: Option<U::Service>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: Option<ServiceConfig>,
|
cfg: Option<ServiceConfig>,
|
||||||
_t: PhantomData<(T, B)>,
|
_phantom: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B, X, U> Future for H1ServiceResponse<T, S, B, X, U>
|
impl<T, S, B, X, U> Future for H1ServiceResponse<T, S, B, X, U>
|
||||||
@ -371,7 +371,7 @@ where
|
|||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B, X, U> H1ServiceHandler<T, S, B, X, U>
|
impl<T, S, B, X, U> H1ServiceHandler<T, S, B, X, U>
|
||||||
@ -398,7 +398,7 @@ where
|
|||||||
upgrade: upgrade.map(CloneableService::new),
|
upgrade: upgrade.map(CloneableService::new),
|
||||||
cfg,
|
cfg,
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
use std::convert::TryFrom;
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::net;
|
use std::net;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
use std::{cmp, convert::TryFrom};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite};
|
use actix_codec::{AsyncRead, AsyncWrite};
|
||||||
use actix_rt::time::{Instant, Sleep};
|
use actix_rt::time::{Instant, Sleep};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
|
use futures_core::ready;
|
||||||
use h2::server::{Connection, SendResponse};
|
use h2::server::{Connection, SendResponse};
|
||||||
use h2::SendStream;
|
use h2::SendStream;
|
||||||
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING};
|
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING};
|
||||||
@ -27,7 +28,7 @@ use crate::Extensions;
|
|||||||
|
|
||||||
const CHUNK_SIZE: usize = 16_384;
|
const CHUNK_SIZE: usize = 16_384;
|
||||||
|
|
||||||
/// Dispatcher for HTTP/2 protocol
|
/// Dispatcher for HTTP/2 protocol.
|
||||||
#[pin_project::pin_project]
|
#[pin_project::pin_project]
|
||||||
pub struct Dispatcher<T, S, B>
|
pub struct Dispatcher<T, S, B>
|
||||||
where
|
where
|
||||||
@ -42,7 +43,7 @@ where
|
|||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
ka_expire: Instant,
|
ka_expire: Instant,
|
||||||
ka_timer: Option<Sleep>,
|
ka_timer: Option<Sleep>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> Dispatcher<T, S, B>
|
impl<T, S, B> Dispatcher<T, S, B>
|
||||||
@ -50,7 +51,6 @@ where
|
|||||||
T: AsyncRead + AsyncWrite + Unpin,
|
T: AsyncRead + AsyncWrite + Unpin,
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
S::Error: Into<Error>,
|
S::Error: Into<Error>,
|
||||||
// S::Future: 'static,
|
|
||||||
S::Response: Into<Response<B>>,
|
S::Response: Into<Response<B>>,
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
{
|
{
|
||||||
@ -86,7 +86,7 @@ where
|
|||||||
on_connect_data,
|
on_connect_data,
|
||||||
ka_expire,
|
ka_expire,
|
||||||
ka_timer,
|
ka_timer,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,10 +107,12 @@ where
|
|||||||
let this = self.get_mut();
|
let this = self.get_mut();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match Pin::new(&mut this.connection).poll_accept(cx) {
|
match ready!(Pin::new(&mut this.connection).poll_accept(cx)) {
|
||||||
Poll::Ready(None) => return Poll::Ready(Ok(())),
|
None => return Poll::Ready(Ok(())),
|
||||||
Poll::Ready(Some(Err(err))) => return Poll::Ready(Err(err.into())),
|
|
||||||
Poll::Ready(Some(Ok((req, res)))) => {
|
Some(Err(err)) => return Poll::Ready(Err(err.into())),
|
||||||
|
|
||||||
|
Some(Ok((req, res))) => {
|
||||||
// update keep-alive expire
|
// update keep-alive expire
|
||||||
if this.ka_timer.is_some() {
|
if this.ka_timer.is_some() {
|
||||||
if let Some(expire) = this.config.keep_alive_expire() {
|
if let Some(expire) = this.config.keep_alive_expire() {
|
||||||
@ -119,11 +121,9 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
let (parts, body) = req.into_parts();
|
let (parts, body) = req.into_parts();
|
||||||
let mut req = Request::with_payload(Payload::<
|
let pl = crate::h2::Payload::new(body);
|
||||||
crate::payload::PayloadStream,
|
let pl = Payload::<crate::payload::PayloadStream>::H2(pl);
|
||||||
>::H2(
|
let mut req = Request::with_payload(pl);
|
||||||
crate::h2::Payload::new(body)
|
|
||||||
));
|
|
||||||
|
|
||||||
let head = &mut req.head_mut();
|
let head = &mut req.head_mut();
|
||||||
head.uri = parts.uri;
|
head.uri = parts.uri;
|
||||||
@ -135,22 +135,18 @@ where
|
|||||||
// merge on_connect_ext data into request extensions
|
// merge on_connect_ext data into request extensions
|
||||||
req.extensions_mut().drain_from(&mut this.on_connect_data);
|
req.extensions_mut().drain_from(&mut this.on_connect_data);
|
||||||
|
|
||||||
actix_rt::spawn(ServiceResponse::<
|
let svc = ServiceResponse::<S::Future, S::Response, S::Error, B> {
|
||||||
S::Future,
|
|
||||||
S::Response,
|
|
||||||
S::Error,
|
|
||||||
B,
|
|
||||||
> {
|
|
||||||
state: ServiceResponseState::ServiceCall(
|
state: ServiceResponseState::ServiceCall(
|
||||||
this.service.call(req),
|
this.service.call(req),
|
||||||
Some(res),
|
Some(res),
|
||||||
),
|
),
|
||||||
config: this.config.clone(),
|
config: this.config.clone(),
|
||||||
buffer: None,
|
buffer: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
actix_rt::spawn(svc);
|
||||||
}
|
}
|
||||||
Poll::Pending => return Poll::Pending,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +158,7 @@ struct ServiceResponse<F, I, E, B> {
|
|||||||
state: ServiceResponseState<F, B>,
|
state: ServiceResponseState<F, B>,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
buffer: Option<Bytes>,
|
buffer: Option<Bytes>,
|
||||||
_t: PhantomData<(I, E)>,
|
_phantom: PhantomData<(I, E)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pin_project::pin_project(project = ServiceResponseStateProj)]
|
#[pin_project::pin_project(project = ServiceResponseStateProj)]
|
||||||
@ -199,8 +195,9 @@ where
|
|||||||
skip_len = true;
|
skip_len = true;
|
||||||
*size = BodySize::Stream;
|
*size = BodySize::Stream;
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = match size {
|
let _ = match size {
|
||||||
BodySize::None | BodySize::Stream => None,
|
BodySize::None | BodySize::Stream => None,
|
||||||
BodySize::Empty => res
|
BodySize::Empty => res
|
||||||
@ -215,11 +212,13 @@ where
|
|||||||
// copy headers
|
// copy headers
|
||||||
for (key, value) in head.headers.iter() {
|
for (key, value) in head.headers.iter() {
|
||||||
match *key {
|
match *key {
|
||||||
CONNECTION | TRANSFER_ENCODING => continue, // http2 specific
|
// omit HTTP/1 only headers
|
||||||
|
CONNECTION | TRANSFER_ENCODING => continue,
|
||||||
CONTENT_LENGTH if skip_len => continue,
|
CONTENT_LENGTH if skip_len => continue,
|
||||||
DATE => has_date = true,
|
DATE => has_date = true,
|
||||||
_ => (),
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
res.headers_mut().append(key, value.clone());
|
res.headers_mut().append(key, value.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,18 +250,20 @@ where
|
|||||||
let mut this = self.as_mut().project();
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
match this.state.project() {
|
match this.state.project() {
|
||||||
ServiceResponseStateProj::ServiceCall(call, send) => match call.poll(cx) {
|
ServiceResponseStateProj::ServiceCall(call, send) => {
|
||||||
Poll::Ready(Ok(res)) => {
|
match ready!(call.poll(cx)) {
|
||||||
|
Ok(res) => {
|
||||||
let (res, body) = res.into().replace_body(());
|
let (res, body) = res.into().replace_body(());
|
||||||
|
|
||||||
let mut send = send.take().unwrap();
|
let mut send = send.take().unwrap();
|
||||||
let mut size = body.size();
|
let mut size = body.size();
|
||||||
let h2_res = self.as_mut().prepare_response(res.head(), &mut size);
|
let h2_res =
|
||||||
|
self.as_mut().prepare_response(res.head(), &mut size);
|
||||||
this = self.as_mut().project();
|
this = self.as_mut().project();
|
||||||
|
|
||||||
let stream = match send.send_response(h2_res, size.is_eof()) {
|
let stream = match send.send_response(h2_res, size.is_eof()) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace!("Error sending h2 response: {:?}", e);
|
trace!("Error sending HTTP/2 response: {:?}", e);
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
Ok(stream) => stream,
|
Ok(stream) => stream,
|
||||||
@ -276,19 +277,20 @@ where
|
|||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
|
||||||
Poll::Ready(Err(e)) => {
|
Err(e) => {
|
||||||
let res: Response = e.into().into();
|
let res: Response = e.into().into();
|
||||||
let (res, body) = res.replace_body(());
|
let (res, body) = res.replace_body(());
|
||||||
|
|
||||||
let mut send = send.take().unwrap();
|
let mut send = send.take().unwrap();
|
||||||
let mut size = body.size();
|
let mut size = body.size();
|
||||||
let h2_res = self.as_mut().prepare_response(res.head(), &mut size);
|
let h2_res =
|
||||||
|
self.as_mut().prepare_response(res.head(), &mut size);
|
||||||
this = self.as_mut().project();
|
this = self.as_mut().project();
|
||||||
|
|
||||||
let stream = match send.send_response(h2_res, size.is_eof()) {
|
let stream = match send.send_response(h2_res, size.is_eof()) {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
trace!("Error sending h2 response: {:?}", e);
|
trace!("Error sending HTTP/2 response: {:?}", e);
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
Ok(stream) => stream,
|
Ok(stream) => stream,
|
||||||
@ -304,56 +306,61 @@ where
|
|||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ServiceResponseStateProj::SendPayload(ref mut stream, ref mut body) => {
|
ServiceResponseStateProj::SendPayload(ref mut stream, ref mut body) => {
|
||||||
loop {
|
loop {
|
||||||
loop {
|
loop {
|
||||||
if let Some(ref mut buffer) = this.buffer {
|
match this.buffer {
|
||||||
match stream.poll_capacity(cx) {
|
Some(ref mut buffer) => {
|
||||||
Poll::Pending => return Poll::Pending,
|
match ready!(stream.poll_capacity(cx)) {
|
||||||
Poll::Ready(None) => return Poll::Ready(()),
|
None => return Poll::Ready(()),
|
||||||
Poll::Ready(Some(Ok(cap))) => {
|
|
||||||
|
Some(Ok(cap)) => {
|
||||||
let len = buffer.len();
|
let len = buffer.len();
|
||||||
let bytes = buffer.split_to(std::cmp::min(cap, len));
|
let bytes = buffer.split_to(cmp::min(cap, len));
|
||||||
|
|
||||||
if let Err(e) = stream.send_data(bytes, false) {
|
if let Err(e) = stream.send_data(bytes, false) {
|
||||||
warn!("{:?}", e);
|
warn!("{:?}", e);
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
} else if !buffer.is_empty() {
|
} else if !buffer.is_empty() {
|
||||||
let cap =
|
let cap = cmp::min(buffer.len(), CHUNK_SIZE);
|
||||||
std::cmp::min(buffer.len(), CHUNK_SIZE);
|
|
||||||
stream.reserve_capacity(cap);
|
stream.reserve_capacity(cap);
|
||||||
} else {
|
} else {
|
||||||
this.buffer.take();
|
this.buffer.take();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Poll::Ready(Some(Err(e))) => {
|
|
||||||
|
Some(Err(e)) => {
|
||||||
warn!("{:?}", e);
|
warn!("{:?}", e);
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
match body.as_mut().poll_next(cx) {
|
|
||||||
Poll::Pending => return Poll::Pending,
|
None => match ready!(body.as_mut().poll_next(cx)) {
|
||||||
Poll::Ready(None) => {
|
None => {
|
||||||
if let Err(e) = stream.send_data(Bytes::new(), true)
|
if let Err(e) = stream.send_data(Bytes::new(), true)
|
||||||
{
|
{
|
||||||
warn!("{:?}", e);
|
warn!("{:?}", e);
|
||||||
}
|
}
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
Poll::Ready(Some(Ok(chunk))) => {
|
|
||||||
stream.reserve_capacity(std::cmp::min(
|
Some(Ok(chunk)) => {
|
||||||
|
stream.reserve_capacity(cmp::min(
|
||||||
chunk.len(),
|
chunk.len(),
|
||||||
CHUNK_SIZE,
|
CHUNK_SIZE,
|
||||||
));
|
));
|
||||||
*this.buffer = Some(chunk);
|
*this.buffer = Some(chunk);
|
||||||
}
|
}
|
||||||
Poll::Ready(Some(Err(e))) => {
|
|
||||||
|
Some(Err(e)) => {
|
||||||
error!("Response payload stream error: {:?}", e);
|
error!("Response payload stream error: {:?}", e);
|
||||||
return Poll::Ready(());
|
return Poll::Ready(());
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
//! HTTP/2 implementation
|
//! HTTP/2 implementation.
|
||||||
use std::pin::Pin;
|
|
||||||
use std::task::{Context, Poll};
|
use std::{
|
||||||
|
pin::Pin,
|
||||||
|
task::{Context, Poll},
|
||||||
|
};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::Stream;
|
use futures_core::{ready, Stream};
|
||||||
use h2::RecvStream;
|
use h2::RecvStream;
|
||||||
|
|
||||||
mod dispatcher;
|
mod dispatcher;
|
||||||
@ -13,14 +16,14 @@ pub use self::dispatcher::Dispatcher;
|
|||||||
pub use self::service::H2Service;
|
pub use self::service::H2Service;
|
||||||
use crate::error::PayloadError;
|
use crate::error::PayloadError;
|
||||||
|
|
||||||
/// H2 receive stream
|
/// HTTP/2 peer stream.
|
||||||
pub struct Payload {
|
pub struct Payload {
|
||||||
pl: RecvStream,
|
stream: RecvStream,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Payload {
|
impl Payload {
|
||||||
pub(crate) fn new(pl: RecvStream) -> Self {
|
pub(crate) fn new(stream: RecvStream) -> Self {
|
||||||
Self { pl }
|
Self { stream }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,18 +36,17 @@ impl Stream for Payload {
|
|||||||
) -> Poll<Option<Self::Item>> {
|
) -> Poll<Option<Self::Item>> {
|
||||||
let this = self.get_mut();
|
let this = self.get_mut();
|
||||||
|
|
||||||
match Pin::new(&mut this.pl).poll_data(cx) {
|
match ready!(Pin::new(&mut this.stream).poll_data(cx)) {
|
||||||
Poll::Ready(Some(Ok(chunk))) => {
|
Some(Ok(chunk)) => {
|
||||||
let len = chunk.len();
|
let len = chunk.len();
|
||||||
if let Err(err) = this.pl.flow_control().release_capacity(len) {
|
|
||||||
Poll::Ready(Some(Err(err.into())))
|
match this.stream.flow_control().release_capacity(len) {
|
||||||
} else {
|
Ok(()) => Poll::Ready(Some(Ok(chunk))),
|
||||||
Poll::Ready(Some(Ok(chunk)))
|
Err(err) => Poll::Ready(Some(Err(err.into()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Poll::Ready(Some(Err(err))) => Poll::Ready(Some(Err(err.into()))),
|
Some(Err(err)) => Poll::Ready(Some(Err(err.into()))),
|
||||||
Poll::Pending => Poll::Pending,
|
None => Poll::Ready(None),
|
||||||
Poll::Ready(None) => Poll::Ready(None),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,12 +26,12 @@ use crate::{ConnectCallback, Extensions};
|
|||||||
|
|
||||||
use super::dispatcher::Dispatcher;
|
use super::dispatcher::Dispatcher;
|
||||||
|
|
||||||
/// `ServiceFactory` implementation for HTTP2 transport
|
/// `ServiceFactory` implementation for HTTP/2 transport
|
||||||
pub struct H2Service<T, S, B> {
|
pub struct H2Service<T, S, B> {
|
||||||
srv: S,
|
srv: S,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<(T, B)>,
|
_phantom: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> H2Service<T, S, B>
|
impl<T, S, B> H2Service<T, S, B>
|
||||||
@ -42,7 +42,7 @@ where
|
|||||||
<S::Service as Service<Request>>::Future: 'static,
|
<S::Service as Service<Request>>::Future: 'static,
|
||||||
B: MessageBody + 'static,
|
B: MessageBody + 'static,
|
||||||
{
|
{
|
||||||
/// Create new `HttpService` instance with config.
|
/// Create new `H2Service` instance with config.
|
||||||
pub(crate) fn with_config<F: IntoServiceFactory<S, Request>>(
|
pub(crate) fn with_config<F: IntoServiceFactory<S, Request>>(
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
service: F,
|
service: F,
|
||||||
@ -51,7 +51,7 @@ where
|
|||||||
cfg,
|
cfg,
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
srv: service.into_factory(),
|
srv: service.into_factory(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ where
|
|||||||
<S::Service as Service<Request>>::Future: 'static,
|
<S::Service as Service<Request>>::Future: 'static,
|
||||||
B: MessageBody + 'static,
|
B: MessageBody + 'static,
|
||||||
{
|
{
|
||||||
/// Create simple tcp based service
|
/// Create plain TCP based service
|
||||||
pub fn tcp(
|
pub fn tcp(
|
||||||
self,
|
self,
|
||||||
) -> impl ServiceFactory<
|
) -> impl ServiceFactory<
|
||||||
@ -106,7 +106,7 @@ mod openssl {
|
|||||||
<S::Service as Service<Request>>::Future: 'static,
|
<S::Service as Service<Request>>::Future: 'static,
|
||||||
B: MessageBody + 'static,
|
B: MessageBody + 'static,
|
||||||
{
|
{
|
||||||
/// Create ssl based service
|
/// Create OpenSSL based service
|
||||||
pub fn openssl(
|
pub fn openssl(
|
||||||
self,
|
self,
|
||||||
acceptor: SslAcceptor,
|
acceptor: SslAcceptor,
|
||||||
@ -149,7 +149,7 @@ mod rustls {
|
|||||||
<S::Service as Service<Request>>::Future: 'static,
|
<S::Service as Service<Request>>::Future: 'static,
|
||||||
B: MessageBody + 'static,
|
B: MessageBody + 'static,
|
||||||
{
|
{
|
||||||
/// Create openssl based service
|
/// Create Rustls based service
|
||||||
pub fn rustls(
|
pub fn rustls(
|
||||||
self,
|
self,
|
||||||
mut config: ServerConfig,
|
mut config: ServerConfig,
|
||||||
@ -200,7 +200,7 @@ where
|
|||||||
fut: self.srv.new_service(()),
|
fut: self.srv.new_service(()),
|
||||||
cfg: Some(self.cfg.clone()),
|
cfg: Some(self.cfg.clone()),
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,7 +215,7 @@ where
|
|||||||
fut: S::Future,
|
fut: S::Future,
|
||||||
cfg: Option<ServiceConfig>,
|
cfg: Option<ServiceConfig>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> Future for H2ServiceResponse<T, S, B>
|
impl<T, S, B> Future for H2ServiceResponse<T, S, B>
|
||||||
@ -232,14 +232,14 @@ where
|
|||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
let this = self.as_mut().project();
|
let this = self.as_mut().project();
|
||||||
|
|
||||||
Poll::Ready(ready!(this.fut.poll(cx)).map(|service| {
|
this.fut.poll(cx).map_ok(|service| {
|
||||||
let this = self.as_mut().project();
|
let this = self.as_mut().project();
|
||||||
H2ServiceHandler::new(
|
H2ServiceHandler::new(
|
||||||
this.cfg.take().unwrap(),
|
this.cfg.take().unwrap(),
|
||||||
this.on_connect_ext.clone(),
|
this.on_connect_ext.clone(),
|
||||||
service,
|
service,
|
||||||
)
|
)
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ where
|
|||||||
srv: CloneableService<S>,
|
srv: CloneableService<S>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> H2ServiceHandler<T, S, B>
|
impl<T, S, B> H2ServiceHandler<T, S, B>
|
||||||
@ -271,7 +271,7 @@ where
|
|||||||
cfg,
|
cfg,
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
srv: CloneableService::new(srv),
|
srv: CloneableService::new(srv),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -363,8 +363,8 @@ where
|
|||||||
ref peer_addr,
|
ref peer_addr,
|
||||||
ref mut on_connect_data,
|
ref mut on_connect_data,
|
||||||
ref mut handshake,
|
ref mut handshake,
|
||||||
) => match Pin::new(handshake).poll(cx) {
|
) => match ready!(Pin::new(handshake).poll(cx)) {
|
||||||
Poll::Ready(Ok(conn)) => {
|
Ok(conn) => {
|
||||||
self.state = State::Incoming(Dispatcher::new(
|
self.state = State::Incoming(Dispatcher::new(
|
||||||
srv.take().unwrap(),
|
srv.take().unwrap(),
|
||||||
conn,
|
conn,
|
||||||
@ -375,11 +375,10 @@ where
|
|||||||
));
|
));
|
||||||
self.poll(cx)
|
self.poll(cx)
|
||||||
}
|
}
|
||||||
Poll::Ready(Err(err)) => {
|
Err(err) => {
|
||||||
trace!("H2 handshake error: {}", err);
|
trace!("H2 handshake error: {}", err);
|
||||||
Poll::Ready(Err(err.into()))
|
Poll::Ready(Err(err.into()))
|
||||||
}
|
}
|
||||||
Poll::Pending => Poll::Pending,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ pub struct HttpService<T, S, B, X = h1::ExpectHandler, U = h1::UpgradeHandler> {
|
|||||||
expect: X,
|
expect: X,
|
||||||
upgrade: Option<U>,
|
upgrade: Option<U>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B> HttpService<T, S, B>
|
impl<T, S, B> HttpService<T, S, B>
|
||||||
@ -65,7 +65,7 @@ where
|
|||||||
expect: h1::ExpectHandler,
|
expect: h1::ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ where
|
|||||||
expect: h1::ExpectHandler,
|
expect: h1::ExpectHandler,
|
||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: None,
|
on_connect_ext: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ where
|
|||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
upgrade: self.upgrade,
|
upgrade: self.upgrade,
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ where
|
|||||||
srv: self.srv,
|
srv: self.srv,
|
||||||
expect: self.expect,
|
expect: self.expect,
|
||||||
on_connect_ext: self.on_connect_ext,
|
on_connect_ext: self.on_connect_ext,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +348,7 @@ where
|
|||||||
upgrade: None,
|
upgrade: None,
|
||||||
on_connect_ext: self.on_connect_ext.clone(),
|
on_connect_ext: self.on_connect_ext.clone(),
|
||||||
cfg: self.cfg.clone(),
|
cfg: self.cfg.clone(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ where
|
|||||||
upgrade: Option<U::Service>,
|
upgrade: Option<U::Service>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
_t: PhantomData<(T, B)>,
|
_phantom: PhantomData<(T, B)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B, X, U> Future for HttpServiceResponse<T, S, B, X, U>
|
impl<T, S, B, X, U> Future for HttpServiceResponse<T, S, B, X, U>
|
||||||
@ -446,7 +446,7 @@ where
|
|||||||
upgrade: Option<CloneableService<U>>,
|
upgrade: Option<CloneableService<U>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, S, B, X, U> HttpServiceHandler<T, S, B, X, U>
|
impl<T, S, B, X, U> HttpServiceHandler<T, S, B, X, U>
|
||||||
@ -474,7 +474,7 @@ where
|
|||||||
srv: CloneableService::new(srv),
|
srv: CloneableService::new(srv),
|
||||||
expect: CloneableService::new(expect),
|
expect: CloneableService::new(expect),
|
||||||
upgrade: upgrade.map(CloneableService::new),
|
upgrade: upgrade.map(CloneableService::new),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,7 @@ impl Encoder<Message> for Codec {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::Nop => (),
|
Message::Nop => {},
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ impl Parser {
|
|||||||
debug!("Received close frame with payload length exceeding 125. Morphing to protocol close frame.");
|
debug!("Received close frame with payload length exceeding 125. Morphing to protocol close frame.");
|
||||||
return Ok(Some((true, OpCode::Close, None)));
|
return Ok(Some((true, OpCode::Close, None)));
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmask
|
// unmask
|
||||||
|
@ -222,7 +222,7 @@ mod test {
|
|||||||
macro_rules! opcode_into {
|
macro_rules! opcode_into {
|
||||||
($from:expr => $opcode:pat) => {
|
($from:expr => $opcode:pat) => {
|
||||||
match OpCode::from($from) {
|
match OpCode::from($from) {
|
||||||
e @ $opcode => (),
|
e @ $opcode => {},
|
||||||
e => unreachable!("{:?}", e),
|
e => unreachable!("{:?}", e),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -232,7 +232,7 @@ mod test {
|
|||||||
($from:expr => $opcode:pat) => {
|
($from:expr => $opcode:pat) => {
|
||||||
let res: u8 = $from.into();
|
let res: u8 = $from.into();
|
||||||
match res {
|
match res {
|
||||||
e @ $opcode => (),
|
e @ $opcode => {},
|
||||||
e => unreachable!("{:?}", e),
|
e => unreachable!("{:?}", e),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -326,7 +326,7 @@ impl InnerMultipart {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
// read field headers for next field
|
// read field headers for next field
|
||||||
@ -835,7 +835,7 @@ mod tests {
|
|||||||
async fn test_boundary() {
|
async fn test_boundary() {
|
||||||
let headers = HeaderMap::new();
|
let headers = HeaderMap::new();
|
||||||
match Multipart::boundary(&headers) {
|
match Multipart::boundary(&headers) {
|
||||||
Err(MultipartError::NoContentType) => (),
|
Err(MultipartError::NoContentType) => {},
|
||||||
_ => unreachable!("should not happen"),
|
_ => unreachable!("should not happen"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -846,7 +846,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
match Multipart::boundary(&headers) {
|
match Multipart::boundary(&headers) {
|
||||||
Err(MultipartError::ParseContentType) => (),
|
Err(MultipartError::ParseContentType) => {},
|
||||||
_ => unreachable!("should not happen"),
|
_ => unreachable!("should not happen"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,7 +856,7 @@ mod tests {
|
|||||||
header::HeaderValue::from_static("multipart/mixed"),
|
header::HeaderValue::from_static("multipart/mixed"),
|
||||||
);
|
);
|
||||||
match Multipart::boundary(&headers) {
|
match Multipart::boundary(&headers) {
|
||||||
Err(MultipartError::Boundary) => (),
|
Err(MultipartError::Boundary) => {},
|
||||||
_ => unreachable!("should not happen"),
|
_ => unreachable!("should not happen"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,17 +956,17 @@ mod tests {
|
|||||||
let mut multipart = Multipart::new(&headers, payload);
|
let mut multipart = Multipart::new(&headers, payload);
|
||||||
|
|
||||||
match multipart.next().await.unwrap() {
|
match multipart.next().await.unwrap() {
|
||||||
Ok(_) => (),
|
Ok(_) => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
match multipart.next().await.unwrap() {
|
match multipart.next().await.unwrap() {
|
||||||
Ok(_) => (),
|
Ok(_) => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
match multipart.next().await {
|
match multipart.next().await {
|
||||||
None => (),
|
None => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -993,7 +993,7 @@ mod tests {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
match field.next().await {
|
match field.next().await {
|
||||||
None => (),
|
None => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1010,7 +1010,7 @@ mod tests {
|
|||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
match field.next().await {
|
match field.next().await {
|
||||||
None => (),
|
None => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1018,7 +1018,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match multipart.next().await {
|
match multipart.next().await {
|
||||||
None => (),
|
None => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1066,7 +1066,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
match multipart.next().await {
|
match multipart.next().await {
|
||||||
None => (),
|
None => {},
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for Ws {
|
|||||||
ws::Message::Text(text) => ctx.text(text),
|
ws::Message::Text(text) => ctx.text(text),
|
||||||
ws::Message::Binary(bin) => ctx.binary(bin),
|
ws::Message::Binary(bin) => ctx.binary(bin),
|
||||||
ws::Message::Close(reason) => ctx.close(reason),
|
ws::Message::Close(reason) => ctx.close(reason),
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ impl ClientRequest {
|
|||||||
return Err(InvalidUrl::MissingScheme.into());
|
return Err(InvalidUrl::MissingScheme.into());
|
||||||
} else if let Some(scheme) = uri.scheme() {
|
} else if let Some(scheme) = uri.scheme() {
|
||||||
match scheme.as_str() {
|
match scheme.as_str() {
|
||||||
"http" | "ws" | "https" | "wss" => (),
|
"http" | "ws" | "https" | "wss" => {},
|
||||||
_ => return Err(InvalidUrl::UnknownScheme.into()),
|
_ => return Err(InvalidUrl::UnknownScheme.into()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -234,7 +234,7 @@ pub struct JsonBody<S, U> {
|
|||||||
length: Option<usize>,
|
length: Option<usize>,
|
||||||
err: Option<JsonPayloadError>,
|
err: Option<JsonPayloadError>,
|
||||||
fut: Option<ReadBody<S>>,
|
fut: Option<ReadBody<S>>,
|
||||||
_t: PhantomData<U>,
|
_phantom: PhantomData<U>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, U> JsonBody<S, U>
|
impl<S, U> JsonBody<S, U>
|
||||||
@ -255,7 +255,7 @@ where
|
|||||||
length: None,
|
length: None,
|
||||||
fut: None,
|
fut: None,
|
||||||
err: Some(JsonPayloadError::ContentType),
|
err: Some(JsonPayloadError::ContentType),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ where
|
|||||||
length: len,
|
length: len,
|
||||||
err: None,
|
err: None,
|
||||||
fut: Some(ReadBody::new(req.take_payload(), 65536)),
|
fut: Some(ReadBody::new(req.take_payload(), 65536)),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,14 +370,14 @@ mod tests {
|
|||||||
async fn test_body() {
|
async fn test_body() {
|
||||||
let mut req = TestResponse::with_header(header::CONTENT_LENGTH, "xxxx").finish();
|
let mut req = TestResponse::with_header(header::CONTENT_LENGTH, "xxxx").finish();
|
||||||
match req.body().await.err().unwrap() {
|
match req.body().await.err().unwrap() {
|
||||||
PayloadError::UnknownLength => (),
|
PayloadError::UnknownLength => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut req =
|
let mut req =
|
||||||
TestResponse::with_header(header::CONTENT_LENGTH, "1000000").finish();
|
TestResponse::with_header(header::CONTENT_LENGTH, "1000000").finish();
|
||||||
match req.body().await.err().unwrap() {
|
match req.body().await.err().unwrap() {
|
||||||
PayloadError::Overflow => (),
|
PayloadError::Overflow => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ mod tests {
|
|||||||
.set_payload(Bytes::from_static(b"11111111111111"))
|
.set_payload(Bytes::from_static(b"11111111111111"))
|
||||||
.finish();
|
.finish();
|
||||||
match req.body().limit(5).await.err().unwrap() {
|
match req.body().limit(5).await.err().unwrap() {
|
||||||
PayloadError::Overflow => (),
|
PayloadError::Overflow => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ impl Future for SendClientRequest {
|
|||||||
SendClientRequest::Fut(send, delay, response_decompress) => {
|
SendClientRequest::Fut(send, delay, response_decompress) => {
|
||||||
if delay.is_some() {
|
if delay.is_some() {
|
||||||
match Pin::new(delay.as_mut().unwrap()).poll(cx) {
|
match Pin::new(delay.as_mut().unwrap()).poll(cx) {
|
||||||
Poll::Pending => (),
|
Poll::Pending => {},
|
||||||
_ => return Poll::Ready(Err(SendRequestError::Timeout)),
|
_ => return Poll::Ready(Err(SendRequestError::Timeout)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ impl Future for SendClientRequest {
|
|||||||
SendClientRequest::Fut(send, delay, _) => {
|
SendClientRequest::Fut(send, delay, _) => {
|
||||||
if delay.is_some() {
|
if delay.is_some() {
|
||||||
match Pin::new(delay.as_mut().unwrap()).poll(cx) {
|
match Pin::new(delay.as_mut().unwrap()).poll(cx) {
|
||||||
Poll::Pending => (),
|
Poll::Pending => {},
|
||||||
_ => return Poll::Ready(Err(SendRequestError::Timeout)),
|
_ => return Poll::Ready(Err(SendRequestError::Timeout)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ impl WebsocketsRequest {
|
|||||||
return Err(InvalidUrl::MissingScheme.into());
|
return Err(InvalidUrl::MissingScheme.into());
|
||||||
} else if let Some(scheme) = uri.scheme() {
|
} else if let Some(scheme) = uri.scheme() {
|
||||||
match scheme.as_str() {
|
match scheme.as_str() {
|
||||||
"http" | "ws" | "https" | "wss" => (),
|
"http" | "ws" | "https" | "wss" => {},
|
||||||
_ => return Err(InvalidUrl::UnknownScheme.into()),
|
_ => return Err(InvalidUrl::UnknownScheme.into()),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,7 +127,7 @@ async fn test_timeout() {
|
|||||||
|
|
||||||
let request = client.get(srv.url("/")).send();
|
let request = client.get(srv.url("/")).send();
|
||||||
match request.await {
|
match request.await {
|
||||||
Err(SendRequestError::Timeout) => (),
|
Err(SendRequestError::Timeout) => {},
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ async fn test_timeout_override() {
|
|||||||
.timeout(Duration::from_millis(50))
|
.timeout(Duration::from_millis(50))
|
||||||
.send();
|
.send();
|
||||||
match request.await {
|
match request.await {
|
||||||
Err(SendRequestError::Timeout) => (),
|
Err(SendRequestError::Timeout) => {},
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ pub struct App<T, B> {
|
|||||||
data_factories: Vec<FnDataFactory>,
|
data_factories: Vec<FnDataFactory>,
|
||||||
external: Vec<ResourceDef>,
|
external: Vec<ResourceDef>,
|
||||||
extensions: Extensions,
|
extensions: Extensions,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App<AppEntry, Body> {
|
impl App<AppEntry, Body> {
|
||||||
@ -55,7 +55,7 @@ impl App<AppEntry, Body> {
|
|||||||
factory_ref: fref,
|
factory_ref: fref,
|
||||||
external: Vec::new(),
|
external: Vec::new(),
|
||||||
extensions: Extensions::new(),
|
extensions: Extensions::new(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -381,7 +381,7 @@ where
|
|||||||
factory_ref: self.factory_ref,
|
factory_ref: self.factory_ref,
|
||||||
external: self.external,
|
external: self.external,
|
||||||
extensions: self.extensions,
|
extensions: self.extensions,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +443,7 @@ where
|
|||||||
factory_ref: self.factory_ref,
|
factory_ref: self.factory_ref,
|
||||||
external: self.external,
|
external: self.external,
|
||||||
extensions: self.extensions,
|
extensions: self.extensions,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ where
|
|||||||
),
|
),
|
||||||
config,
|
config,
|
||||||
rmap,
|
rmap,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ where
|
|||||||
data: Rc<[Box<dyn DataFactory>]>,
|
data: Rc<[Box<dyn DataFactory>]>,
|
||||||
extensions: Option<Extensions>,
|
extensions: Option<Extensions>,
|
||||||
|
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B> Future for AppInitResult<T, B>
|
impl<T, B> Future for AppInitResult<T, B>
|
||||||
|
@ -49,7 +49,7 @@ where
|
|||||||
R::Output: Responder,
|
R::Output: Responder,
|
||||||
{
|
{
|
||||||
hnd: F,
|
hnd: F,
|
||||||
_t: PhantomData<(T, R)>,
|
_phantom: PhantomData<(T, R)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, T, R> HandlerService<F, T, R>
|
impl<F, T, R> HandlerService<F, T, R>
|
||||||
@ -62,7 +62,7 @@ where
|
|||||||
pub fn new(hnd: F) -> Self {
|
pub fn new(hnd: F) -> Self {
|
||||||
Self {
|
Self {
|
||||||
hnd,
|
hnd,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ where
|
|||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
hnd: self.hnd.clone(),
|
hnd: self.hnd.clone(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ impl ConnectionInfo {
|
|||||||
host = Some(val.trim());
|
host = Some(val.trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ where
|
|||||||
CompressResponse {
|
CompressResponse {
|
||||||
encoding,
|
encoding,
|
||||||
fut: self.service.call(req),
|
fut: self.service.call(req),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ where
|
|||||||
#[pin]
|
#[pin]
|
||||||
fut: S::Future,
|
fut: S::Future,
|
||||||
encoding: ContentEncoding,
|
encoding: ContentEncoding,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, B> Future for CompressResponse<S, B>
|
impl<S, B> Future for CompressResponse<S, B>
|
||||||
|
@ -236,7 +236,7 @@ where
|
|||||||
fut: self.service.call(req),
|
fut: self.service.call(req),
|
||||||
format: None,
|
format: None,
|
||||||
time: OffsetDateTime::now_utc(),
|
time: OffsetDateTime::now_utc(),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let now = OffsetDateTime::now_utc();
|
let now = OffsetDateTime::now_utc();
|
||||||
@ -249,7 +249,7 @@ where
|
|||||||
fut: self.service.call(req),
|
fut: self.service.call(req),
|
||||||
format: Some(format),
|
format: Some(format),
|
||||||
time: now,
|
time: now,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ where
|
|||||||
fut: S::Future,
|
fut: S::Future,
|
||||||
time: OffsetDateTime,
|
time: OffsetDateTime,
|
||||||
format: Option<Format>,
|
format: Option<Format>,
|
||||||
_t: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, B> Future for LoggerResponse<S, B>
|
impl<S, B> Future for LoggerResponse<S, B>
|
||||||
@ -522,7 +522,7 @@ impl FormatText {
|
|||||||
};
|
};
|
||||||
*self = FormatText::Str(s.to_string())
|
*self = FormatText::Str(s.to_string())
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -587,7 +587,7 @@ impl FormatText {
|
|||||||
|
|
||||||
*self = s;
|
*self = s;
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,14 +349,14 @@ where
|
|||||||
pub struct ResponseFuture<T, E> {
|
pub struct ResponseFuture<T, E> {
|
||||||
#[pin]
|
#[pin]
|
||||||
fut: T,
|
fut: T,
|
||||||
_t: PhantomData<E>,
|
_phantom: PhantomData<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, E> ResponseFuture<T, E> {
|
impl<T, E> ResponseFuture<T, E> {
|
||||||
pub fn new(fut: T) -> Self {
|
pub fn new(fut: T) -> Self {
|
||||||
ResponseFuture {
|
ResponseFuture {
|
||||||
fut,
|
fut,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
fmt, io,
|
cmp, fmt, io,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
net,
|
net,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
@ -71,7 +71,7 @@ where
|
|||||||
sockets: Vec<Socket>,
|
sockets: Vec<Socket>,
|
||||||
builder: ServerBuilder,
|
builder: ServerBuilder,
|
||||||
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
|
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
|
||||||
_t: PhantomData<(S, B)>,
|
_phantom: PhantomData<(S, B)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, I, S, B> HttpServer<F, I, S, B>
|
impl<F, I, S, B> HttpServer<F, I, S, B>
|
||||||
@ -100,7 +100,7 @@ where
|
|||||||
sockets: Vec::new(),
|
sockets: Vec::new(),
|
||||||
builder: ServerBuilder::default(),
|
builder: ServerBuilder::default(),
|
||||||
on_connect_fn: None,
|
on_connect_fn: None,
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ where
|
|||||||
sockets: self.sockets,
|
sockets: self.sockets,
|
||||||
builder: self.builder,
|
builder: self.builder,
|
||||||
on_connect_fn: Some(Arc::new(f)),
|
on_connect_fn: Some(Arc::new(f)),
|
||||||
_t: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,7 +653,7 @@ fn create_tcp_listener(
|
|||||||
socket.set_reuse_address(true)?;
|
socket.set_reuse_address(true)?;
|
||||||
socket.bind(&addr.into())?;
|
socket.bind(&addr.into())?;
|
||||||
// clamp backlog to max u32 that fits in i32 range
|
// clamp backlog to max u32 that fits in i32 range
|
||||||
let backlog = backlog.min(i32::MAX as u32) as i32;
|
let backlog = cmp::min(backlog, i32::MAX as u32) as i32;
|
||||||
socket.listen(backlog)?;
|
socket.listen(backlog)?;
|
||||||
Ok(socket.into_tcp_listener())
|
Ok(socket.into_tcp_listener())
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ mod tests {
|
|||||||
.into_parts();
|
.into_parts();
|
||||||
let res = HttpMessageBody::new(&req, &mut pl).await;
|
let res = HttpMessageBody::new(&req, &mut pl).await;
|
||||||
match res.err().unwrap() {
|
match res.err().unwrap() {
|
||||||
PayloadError::UnknownLength => (),
|
PayloadError::UnknownLength => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ mod tests {
|
|||||||
.into_parts();
|
.into_parts();
|
||||||
let res = HttpMessageBody::new(&req, &mut pl).await;
|
let res = HttpMessageBody::new(&req, &mut pl).await;
|
||||||
match res.err().unwrap() {
|
match res.err().unwrap() {
|
||||||
PayloadError::Overflow => (),
|
PayloadError::Overflow => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ mod tests {
|
|||||||
.to_http_parts();
|
.to_http_parts();
|
||||||
let res = HttpMessageBody::new(&req, &mut pl).limit(5).await;
|
let res = HttpMessageBody::new(&req, &mut pl).limit(5).await;
|
||||||
match res.err().unwrap() {
|
match res.err().unwrap() {
|
||||||
PayloadError::Overflow => (),
|
PayloadError::Overflow => {},
|
||||||
_ => unreachable!("error"),
|
_ => unreachable!("error"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user