pub struct Server<L = HttpListener> {
pub listener: L,
pub timeouts: Timeouts,
}Expand description
A server can listen on a TCP socket.
Once listening, it will create a Request/Response pair for each
incoming connection, and hand them to the provided handler.
Fields§
§listener: L§timeouts: TimeoutsImplementations§
Source§impl<L: NetworkListener> Server<L>
impl<L: NetworkListener> Server<L>
Sourcepub fn keep_alive(self, timeout: Option<Duration>) -> Self
pub fn keep_alive(self, timeout: Option<Duration>) -> Self
Controls keep-alive for this server.
The timeout duration passed will be used to determine how long to keep the connection alive before dropping it.
Passing None will disable keep-alive.
Default is enabled with a 5 second timeout.
Sourcepub fn set_read_timeout(self, dur: Option<Duration>) -> Self
pub fn set_read_timeout(self, dur: Option<Duration>) -> Self
Sets the read timeout for all Request reads.
Sourcepub fn set_write_timeout(self, dur: Option<Duration>) -> Self
pub fn set_write_timeout(self, dur: Option<Duration>) -> Self
Sets the write timeout for all Response writes.
Sourcepub fn set_keep_alive_type(self, t: KeepAliveType) -> Self
pub fn set_keep_alive_type(self, t: KeepAliveType) -> Self
set set_keep_alive_type
Sourcepub fn local_addr(&mut self) -> Result<SocketAddr>
pub fn local_addr(&mut self) -> Result<SocketAddr>
Get the address that the server is listening on.
Source§impl Server<HttpListener>
impl Server<HttpListener>
Sourcepub fn http<To: ToSocketAddrs>(addr: To) -> Result<Server<HttpListener>>
pub fn http<To: ToSocketAddrs>(addr: To) -> Result<Server<HttpListener>>
Creates a new server that will handle HttpStreams.
Source§impl<S: SslServer + Clone + Send> Server<HttpsListener<S>>
impl<S: SslServer + Clone + Send> Server<HttpsListener<S>>
Sourcepub fn https<A: ToSocketAddrs>(
addr: A,
ssl: S,
) -> Result<Server<HttpsListener<S>>>
pub fn https<A: ToSocketAddrs>( addr: A, ssl: S, ) -> Result<Server<HttpsListener<S>>>
Creates a new server that will handle HttpStreams over SSL.
You can use any SSL implementation, as long as implements cogo_http::net::Ssl.
Source§impl<L: NetworkListener + Send + 'static> Server<L>
impl<L: NetworkListener + Send + 'static> Server<L>
Trait Implementations§
Auto Trait Implementations§
impl<L> Freeze for Server<L>where
L: Freeze,
impl<L> RefUnwindSafe for Server<L>where
L: RefUnwindSafe,
impl<L> Send for Server<L>where
L: Send,
impl<L> Sync for Server<L>where
L: Sync,
impl<L> Unpin for Server<L>where
L: Unpin,
impl<L> UnwindSafe for Server<L>where
L: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more