Enum kvarn::application::HttpConnection
source · pub enum HttpConnection {
Http1(Arc<Mutex<Encryption>>),
Http2(Box<Connection<Encryption, Bytes>>),
Http3(Connection<Connection, Bytes>),
}
Expand description
A single HTTP connection.
See HttpConnection::new
on how to make one and
HttpConnection::accept
on getting a FatRequest
.
Variants§
Http1(Arc<Mutex<Encryption>>)
An HTTP/1 connection
Http2(Box<Connection<Encryption, Bytes>>)
Available on crate feature
http2
only.An HTTP/2 connection
This is boxed because a h2::server::Connection
takes up
over 1000 bytes of memory, and an Arc
8 bytes.
It will increase performance on servers with both HTTP/1 and HTTP/2
connections, but slightly hurt exclusively HTTP/2 servers.
We’ll see how we move forward once HTTP/3 support lands.
Http3(Connection<Connection, Bytes>)
Available on crate feature
http3
only.An HTTP/3 conenction.
Implementations§
source§impl HttpConnection
impl HttpConnection
sourcepub async fn new(stream: Encryption, version: Version) -> Result<Self, Error>
pub async fn new(stream: Encryption, version: Version) -> Result<Self, Error>
Creates a new HttpConnection
from an Encryption
stream.
Errors
Returns Error::VersionNotSupported
when a unsupported version is passed.
Also passes errors from h2::server::handshake
.