pub(in crate::http) fn with_timeout(
        config: Rc<DispatcherConfig<S, X, U>>,
        io: T,
        codec: Codec,
        read_buf: BytesMut,
        timeout: Option<Delay>,
        peer_addr: Option<net::SocketAddr>,
        on_connect: Option<Box<dyn DataFactory>>,
    ) -> Self {
        let keepalive = config.keep_alive_enabled();
        let mut flags = if keepalive {
            Flags::KEEPALIVE | Flags::READ_EOF
        } else {
            Flags::READ_EOF
        };
        if config.keep_alive_timer_enabled() {
            flags |= Flags::HAS_KEEPALIVE;
        }

        // keep-alive timer
        let (ka_expire, ka_timer) = if let Some(delay) = timeout {
            (delay.deadline(), Some(delay))
        } else if let Some(delay) = config.keep_alive_timer() {
            (delay.deadline(), Some(delay))
        } else {
            (config.now(), None)
        };

        Dispatcher {
            call: CallState::Io,
            upgrade: None,
            inner: InnerDispatcher {
                write_buf: BytesMut::with_capacity(WRITE_HW_BUFFER_SIZE),
                req_payload: None,
                res_payload: None,
                error: None,
                io: Some(io),
                config,
                codec,
                read_buf,
                flags,
                peer_addr,
                on_connect,
                ka_expire,
                ka_timer,
            },
        }
    }
/// Create http/1 dispatcher with slow request timeout.
Create http/1 dispatcher with slow request timeout.
Create http / 1 dispatcher with slow request timeout .
pub(in crate::http) fn with_timeout(
        config: Rc<DispatcherConfig<S, X, U>>,
        io: T,
        codec: Codec,
        read_buf: BytesMut,
        timeout: Option<Delay>,
        peer_addr: Option<net::SocketAddr>,
        on_connect: Option<Box<dyn DataFactory>>,
    ) -> Self {
        let keepalive = config.keep_alive_enabled();
        let mut flags = if keepalive {
            Flags::KEEPALIVE | Flags::READ_EOF
        } else {
            Flags::READ_EOF
        };
        if config.keep_alive_timer_enabled() {
            flags |= Flags::HAS_KEEPALIVE;
        }
        // keep-alive timer
        let (ka_expire, ka_timer) = if let Some(delay) = timeout {
            (delay.deadline(), Some(delay))
        } else if let Some(delay) = config.keep_alive_timer() {
            (delay.deadline(), Some(delay))
        } else {
            (config.now(), None)
        };
        Dispatcher {
            call: CallState::Io,
            upgrade: None,
            inner: InnerDispatcher {
                write_buf: BytesMut::with_capacity(WRITE_HW_BUFFER_SIZE),
                req_payload: None,
                res_payload: None,
                error: None,
                io: Some(io),
                config,
                codec,
                read_buf,
                flags,
                peer_addr,
                on_connect,
                ka_expire,
                ka_timer,
            },
        }
    }
pub ( in crate :: http ) fn with_timeout ( config : Rc < DispatcherConfig < S , X , U > > , io : T , codec : Codec , read_buf : BytesMut , timeout : Option < Delay > , peer_addr : Option < net :: SocketAddr > , on_connect : Option < Box < dyn DataFactory > > , ) -> Self { let keepalive = config . keep_alive_enabled ( ) ; let mut flags = if keepalive { Flags :: KEEPALIVE | Flags :: READ_EOF } else { Flags :: READ_EOF } ; if config . keep_alive_timer_enabled ( ) { flags |= Flags :: HAS_KEEPALIVE ; } // keep-alive timer let ( ka_expire , ka_timer ) = if let Some ( delay ) = timeout { ( delay . deadline ( ) , Some ( delay ) ) } else if let Some ( delay ) = config . keep_alive_timer ( ) { ( delay . deadline ( ) , Some ( delay ) ) } else { ( config . now ( ) , None ) } ; Dispatcher { call : CallState :: Io , upgrade : None , inner : InnerDispatcher { write_buf : BytesMut :: with_capacity ( WRITE_HW_BUFFER_SIZE ) , req_payload : None , res_payload : None , error : None , io : Some ( io ) , config , codec , read_buf , flags , peer_addr , on_connect , ka_expire , ka_timer , } , } }
Create http/1 dispatcher with slow request timeout.
Create http / 1 dispatcher with slow request timeout .
config
Rc<DispatcherConfig<S, X, U>>
io
T
codec
Codec
read_buf
BytesMut
timeout
Option<Delay>
peer_addr
Option<net::SocketAddr>
on_connect
Option<Box<dyn DataFactory>>