mirror of https://github.com/fafhrd91/actix-web
rename HttpServices to HttpFlow
This commit is contained in:
parent
12de0e96fc
commit
3a6c64fafd
|
@ -23,7 +23,7 @@ use crate::error::{DispatchError, Error};
|
||||||
use crate::error::{ParseError, PayloadError};
|
use crate::error::{ParseError, PayloadError};
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::service::HttpServices;
|
use crate::service::HttpFlow;
|
||||||
use crate::OnConnectData;
|
use crate::OnConnectData;
|
||||||
|
|
||||||
use super::codec::Codec;
|
use super::codec::Codec;
|
||||||
|
@ -91,7 +91,7 @@ where
|
||||||
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
U: Service<(Request, Framed<T, Codec>), Response = ()>,
|
||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
on_connect_data: OnConnectData,
|
on_connect_data: OnConnectData,
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
|
@ -177,7 +177,7 @@ where
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
stream: T,
|
stream: T,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
on_connect_data: OnConnectData,
|
on_connect_data: OnConnectData,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -200,7 +200,7 @@ where
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
read_buf: BytesMut,
|
read_buf: BytesMut,
|
||||||
timeout: Option<Sleep>,
|
timeout: Option<Sleep>,
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
on_connect_data: OnConnectData,
|
on_connect_data: OnConnectData,
|
||||||
peer_addr: Option<net::SocketAddr>,
|
peer_addr: Option<net::SocketAddr>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -561,7 +561,7 @@ where
|
||||||
req.head_mut().peer_addr = *this.peer_addr;
|
req.head_mut().peer_addr = *this.peer_addr;
|
||||||
|
|
||||||
// merge on_connect_ext data into request extensions
|
// merge on_connect_ext data into request extensions
|
||||||
this.on_connect_data.merge(&mut req);
|
this.on_connect_data.merge_into(&mut req);
|
||||||
|
|
||||||
if pl == MessageType::Stream
|
if pl == MessageType::Stream
|
||||||
&& this.services.borrow().upgrade.is_some()
|
&& this.services.borrow().upgrade.is_some()
|
||||||
|
@ -1028,7 +1028,7 @@ mod tests {
|
||||||
lazy(|cx| {
|
lazy(|cx| {
|
||||||
let buf = TestBuffer::new("GET /test HTTP/1\r\n\r\n");
|
let buf = TestBuffer::new("GET /test HTTP/1\r\n\r\n");
|
||||||
|
|
||||||
let services = HttpServices::new(ok_service(), ExpectHandler, None);
|
let services = HttpFlow::new(ok_service(), ExpectHandler, None);
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf,
|
buf,
|
||||||
|
@ -1068,7 +1068,7 @@ mod tests {
|
||||||
|
|
||||||
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
|
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
|
||||||
|
|
||||||
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
|
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf,
|
buf,
|
||||||
|
@ -1122,7 +1122,7 @@ mod tests {
|
||||||
|
|
||||||
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
|
let cfg = ServiceConfig::new(KeepAlive::Disabled, 1, 1, false, None);
|
||||||
|
|
||||||
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
|
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf,
|
buf,
|
||||||
|
@ -1172,8 +1172,7 @@ mod tests {
|
||||||
let mut buf = TestSeqBuffer::empty();
|
let mut buf = TestSeqBuffer::empty();
|
||||||
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
||||||
|
|
||||||
let services =
|
let services = HttpFlow::new(echo_payload_service(), ExpectHandler, None);
|
||||||
HttpServices::new(echo_payload_service(), ExpectHandler, None);
|
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf.clone(),
|
buf.clone(),
|
||||||
|
@ -1245,7 +1244,7 @@ mod tests {
|
||||||
let mut buf = TestSeqBuffer::empty();
|
let mut buf = TestSeqBuffer::empty();
|
||||||
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
||||||
|
|
||||||
let services = HttpServices::new(echo_path_service(), ExpectHandler, None);
|
let services = HttpFlow::new(echo_path_service(), ExpectHandler, None);
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf.clone(),
|
buf.clone(),
|
||||||
|
@ -1306,7 +1305,7 @@ mod tests {
|
||||||
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
let cfg = ServiceConfig::new(KeepAlive::Disabled, 0, 0, false, None);
|
||||||
|
|
||||||
let services =
|
let services =
|
||||||
HttpServices::new(ok_service(), ExpectHandler, Some(UpgradeHandler));
|
HttpFlow::new(ok_service(), ExpectHandler, Some(UpgradeHandler));
|
||||||
|
|
||||||
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
let h1 = Dispatcher::<_, _, _, _, UpgradeHandler>::new(
|
||||||
buf.clone(),
|
buf.clone(),
|
||||||
|
|
|
@ -17,7 +17,7 @@ use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::service::HttpServices;
|
use crate::service::HttpFlow;
|
||||||
use crate::{ConnectCallback, OnConnectData};
|
use crate::{ConnectCallback, OnConnectData};
|
||||||
|
|
||||||
use super::codec::Codec;
|
use super::codec::Codec;
|
||||||
|
@ -367,7 +367,7 @@ where
|
||||||
X: Service<Request>,
|
X: Service<Request>,
|
||||||
U: Service<(Request, Framed<T, Codec>)>,
|
U: Service<(Request, Framed<T, Codec>)>,
|
||||||
{
|
{
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
_phantom: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
|
@ -392,7 +392,7 @@ where
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
) -> H1ServiceHandler<T, S, B, X, U> {
|
) -> H1ServiceHandler<T, S, B, X, U> {
|
||||||
H1ServiceHandler {
|
H1ServiceHandler {
|
||||||
services: HttpServices::new(service, expect, upgrade),
|
services: HttpFlow::new(service, expect, upgrade),
|
||||||
cfg,
|
cfg,
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
|
|
|
@ -24,7 +24,7 @@ use crate::message::ResponseHead;
|
||||||
use crate::payload::Payload;
|
use crate::payload::Payload;
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::service::HttpServices;
|
use crate::service::HttpFlow;
|
||||||
use crate::OnConnectData;
|
use crate::OnConnectData;
|
||||||
|
|
||||||
const CHUNK_SIZE: usize = 16_384;
|
const CHUNK_SIZE: usize = 16_384;
|
||||||
|
@ -37,7 +37,7 @@ where
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
{
|
{
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
connection: Connection<T, Bytes>,
|
connection: Connection<T, Bytes>,
|
||||||
on_connect_data: OnConnectData,
|
on_connect_data: OnConnectData,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
|
@ -56,7 +56,7 @@ where
|
||||||
B: MessageBody,
|
B: MessageBody,
|
||||||
{
|
{
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
connection: Connection<T, Bytes>,
|
connection: Connection<T, Bytes>,
|
||||||
on_connect_data: OnConnectData,
|
on_connect_data: OnConnectData,
|
||||||
config: ServiceConfig,
|
config: ServiceConfig,
|
||||||
|
@ -134,7 +134,7 @@ where
|
||||||
head.peer_addr = this.peer_addr;
|
head.peer_addr = this.peer_addr;
|
||||||
|
|
||||||
// merge on_connect_ext data into request extensions
|
// merge on_connect_ext data into request extensions
|
||||||
this.on_connect_data.merge(&mut req);
|
this.on_connect_data.merge_into(&mut req);
|
||||||
|
|
||||||
let svc = ServiceResponse::<S::Future, S::Response, S::Error, B> {
|
let svc = ServiceResponse::<S::Future, S::Response, S::Error, B> {
|
||||||
state: ServiceResponseState::ServiceCall(
|
state: ServiceResponseState::ServiceCall(
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::config::ServiceConfig;
|
||||||
use crate::error::{DispatchError, Error};
|
use crate::error::{DispatchError, Error};
|
||||||
use crate::request::Request;
|
use crate::request::Request;
|
||||||
use crate::response::Response;
|
use crate::response::Response;
|
||||||
use crate::service::HttpServices;
|
use crate::service::HttpFlow;
|
||||||
use crate::{ConnectCallback, OnConnectData};
|
use crate::{ConnectCallback, OnConnectData};
|
||||||
|
|
||||||
use super::dispatcher::Dispatcher;
|
use super::dispatcher::Dispatcher;
|
||||||
|
@ -249,7 +249,7 @@ pub struct H2ServiceHandler<T, S, B>
|
||||||
where
|
where
|
||||||
S: Service<Request>,
|
S: Service<Request>,
|
||||||
{
|
{
|
||||||
services: Rc<RefCell<HttpServices<S, (), ()>>>,
|
services: Rc<RefCell<HttpFlow<S, (), ()>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_phantom: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
|
@ -269,7 +269,7 @@ where
|
||||||
service: S,
|
service: S,
|
||||||
) -> H2ServiceHandler<T, S, B> {
|
) -> H2ServiceHandler<T, S, B> {
|
||||||
H2ServiceHandler {
|
H2ServiceHandler {
|
||||||
services: HttpServices::new(service, (), None),
|
services: HttpFlow::new(service, (), None),
|
||||||
cfg,
|
cfg,
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
|
@ -325,7 +325,7 @@ where
|
||||||
{
|
{
|
||||||
Incoming(Dispatcher<T, S, B, (), ()>),
|
Incoming(Dispatcher<T, S, B, (), ()>),
|
||||||
Handshake(
|
Handshake(
|
||||||
Option<Rc<RefCell<HttpServices<S, (), ()>>>>,
|
Option<Rc<RefCell<HttpFlow<S, (), ()>>>>,
|
||||||
Option<ServiceConfig>,
|
Option<ServiceConfig>,
|
||||||
Option<net::SocketAddr>,
|
Option<net::SocketAddr>,
|
||||||
OnConnectData,
|
OnConnectData,
|
||||||
|
|
|
@ -441,20 +441,20 @@ where
|
||||||
X: Service<Request>,
|
X: Service<Request>,
|
||||||
U: Service<(Request, Framed<T, h1::Codec>)>,
|
U: Service<(Request, Framed<T, h1::Codec>)>,
|
||||||
{
|
{
|
||||||
services: Rc<RefCell<HttpServices<S, X, U>>>,
|
services: Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
cfg: ServiceConfig,
|
cfg: ServiceConfig,
|
||||||
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
on_connect_ext: Option<Rc<ConnectCallback<T>>>,
|
||||||
_phantom: PhantomData<B>,
|
_phantom: PhantomData<B>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// a collection of service for http.
|
// a collection of service for http.
|
||||||
pub(super) struct HttpServices<S, X, U> {
|
pub(super) struct HttpFlow<S, X, U> {
|
||||||
pub(super) service: S,
|
pub(super) service: S,
|
||||||
pub(super) expect: X,
|
pub(super) expect: X,
|
||||||
pub(super) upgrade: Option<U>,
|
pub(super) upgrade: Option<U>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, X, U> HttpServices<S, X, U> {
|
impl<S, X, U> HttpFlow<S, X, U> {
|
||||||
pub(super) fn new(service: S, expect: X, upgrade: Option<U>) -> Rc<RefCell<Self>> {
|
pub(super) fn new(service: S, expect: X, upgrade: Option<U>) -> Rc<RefCell<Self>> {
|
||||||
Rc::new(RefCell::new(Self {
|
Rc::new(RefCell::new(Self {
|
||||||
service,
|
service,
|
||||||
|
@ -486,7 +486,7 @@ where
|
||||||
HttpServiceHandler {
|
HttpServiceHandler {
|
||||||
cfg,
|
cfg,
|
||||||
on_connect_ext,
|
on_connect_ext,
|
||||||
services: HttpServices::new(service, expect, upgrade),
|
services: HttpFlow::new(service, expect, upgrade),
|
||||||
_phantom: PhantomData,
|
_phantom: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,7 +603,7 @@ where
|
||||||
Option<(
|
Option<(
|
||||||
Handshake<T, Bytes>,
|
Handshake<T, Bytes>,
|
||||||
ServiceConfig,
|
ServiceConfig,
|
||||||
Rc<RefCell<HttpServices<S, X, U>>>,
|
Rc<RefCell<HttpFlow<S, X, U>>>,
|
||||||
OnConnectData,
|
OnConnectData,
|
||||||
Option<net::SocketAddr>,
|
Option<net::SocketAddr>,
|
||||||
)>,
|
)>,
|
||||||
|
|
Loading…
Reference in New Issue