pub struct Session { /* private fields */ }Expand description
A single HTTP(S) connection in progress.
Implementations§
Source§impl Session
impl Session
Sourcepub fn plain(cfg: SessionConfig) -> Session
pub fn plain(cfg: SessionConfig) -> Session
Create a plaintext (HTTP/1.x) session.
Sourcepub fn tls(cfg: SessionConfig, stream: TlsStream) -> Session
pub fn tls(cfg: SessionConfig, stream: TlsStream) -> Session
Create a TLS (HTTPS) session wrapping an accepted
TlsStream. The protocol (HTTP/1.1 or HTTP/2)
is chosen once ALPN is known.
Sourcepub fn received(&mut self, wire_in: &[u8]) -> Result<()>
pub fn received(&mut self, wire_in: &[u8]) -> Result<()>
Feed bytes received from the socket: decrypt, (lazily) select the protocol, parse requests, run the handler, and queue responses.
Sourcepub fn to_send(&mut self) -> Result<Vec<u8>>
pub fn to_send(&mut self) -> Result<Vec<u8>>
Produce the bytes to write to the socket: TLS handshake records and/or (encrypted) response data. May be empty.
Sourcepub fn has_output(&self) -> bool
pub fn has_output(&self) -> bool
Whether the engine still has output to produce — queued bytes or a
response body (e.g. a file) being streamed in chunks. Drivers must keep
calling to_send while this is true before waiting for
the next read or closing, so a body is flushed in full.
Sourcepub fn wants_close(&self) -> bool
pub fn wants_close(&self) -> bool
Whether the connection should be closed once pending output is written.
Sourcepub fn handshaking(&self) -> bool
pub fn handshaking(&self) -> bool
Whether the session is still completing the TLS handshake.