Skip to content

Commit

Permalink
feat(server): expose methods for determining if HTTP/1.1 or HTTP/2 su…
Browse files Browse the repository at this point in the history
…pport are enabled (#164)
  • Loading branch information
tobz authored Jan 28, 2025
1 parent 0c402d8 commit 26e1e15
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/server/conn/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,30 @@ impl<E> Builder<E> {
self
}

/// Returns `true` if this builder can serve an HTTP/1.1-based connection.
pub fn is_http1_available(&self) -> bool {
match self.version {
#[cfg(feature = "http1")]
Some(Version::H1) => true,
#[cfg(feature = "http2")]
Some(Version::H2) => false,
#[cfg(any(feature = "http1", feature = "http2"))]
_ => true,
}
}

/// Returns `true` if this builder can serve an HTTP/2-based connection.
pub fn is_http2_available(&self) -> bool {
match self.version {
#[cfg(feature = "http1")]
Some(Version::H1) => false,
#[cfg(feature = "http2")]
Some(Version::H2) => true,
#[cfg(any(feature = "http1", feature = "http2"))]
_ => true,
}
}

/// Bind a connection together with a [`Service`].
pub fn serve_connection<I, S, B>(&self, io: I, service: S) -> Connection<'_, I, S, E>
where
Expand Down

0 comments on commit 26e1e15

Please sign in to comment.