microserve::detail namespace

Internal HTTP/1.1 session implementations.

Cleartext (Http1Session) and TLS (H1SecureSession) request/response loops used after protocol detection. Not part of the public API.

Classes

struct H2StreamState
struct H2BodyHolder
template<typename Derived, typename Stream>
class H2SessionBase
class Http1Session
HTTP/1.1 session over a plain TCP socket.
class H1SecureSession
HTTP/1.1 session over TLS.

Functions

auto is_hop_by_hop_header(std::string_view name) -> bool
void append_response_headers(const Response& res, std::vector<std::string>& storage)
template<typename Socket>
void open_and_bind(Socket& sock, const typename Socket::endpoint_type& ep)
Open sock, set SO_REUSEADDR, and IPV6_V6ONLY when ep is IPv6.
template<typename Acceptor>
void open_bind_listen(Acceptor& acc, const typename Acceptor::endpoint_type& ep)
void load_tls_certificate(net::ssl::context& ctx, const std::string& cert_file, const std::string& key_file, const std::string_view tag = "https")
Load a PEM certificate chain + private key into an Asio TLS context.

Variables

std::string_view kH2Preface constexpr

Function documentation

bool microserve::detail::is_hop_by_hop_header(std::string_view name)

void microserve::detail::append_response_headers(const Response& res, std::vector<std::string>& storage)

template<typename Socket>
void microserve::detail::open_and_bind(Socket& sock, const typename Socket::endpoint_type& ep)

Open sock, set SO_REUSEADDR, and IPV6_V6ONLY when ep is IPv6.

Linux defaults to dual-stack IPv6 (net.ipv6.bindv6only=0). Binding [::] then also occupies 0.0.0.0 for that protocol, so a later IPv4+IPv6 pair (or the reverse) fails with EADDRINUSE. Windows is already v6-only by default; setting the option there is a no-op.

template<typename Acceptor>
void microserve::detail::open_bind_listen(Acceptor& acc, const typename Acceptor::endpoint_type& ep)

void microserve::detail::load_tls_certificate(net::ssl::context& ctx, const std::string& cert_file, const std::string& key_file, const std::string_view tag = "https")

Load a PEM certificate chain + private key into an Asio TLS context.

Logs the same way HTTP/3 does, then throws std::runtime_error.

Variable documentation

std::string_view microserve::detail::kH2Preface constexpr