microserve::detail::Http1Session class

HTTP/1.1 session over a plain TCP socket.

Runs a keep-alive request/response loop with Beast async_read / async_write and the configured read/write timeouts.

Constructors, destructors, conversion operators

Http1Session(tcp::socket socket, Handler& handler, Config::TimeoutConfig& timeout, const int verbosity, const std::string_view tag = "h11")
Construct a session that reads from a fresh socket.
Http1Session(tcp::socket socket, const uint8_t* prefix, const std::size_t n, Handler& handler, Config::TimeoutConfig& timeout, const int verbosity, const std::string_view tag = "h11")
Construct a session that already has probe bytes buffered.

Public functions

void start()
Start the request/response loop.
void stop()
Cancel outstanding operations and close the socket.

Function documentation

microserve::detail::Http1Session::Http1Session(tcp::socket socket, Handler& handler, Config::TimeoutConfig& timeout, const int verbosity, const std::string_view tag = "h11")

Construct a session that reads from a fresh socket.

Parameters
socket Connected TCP socket, moved in.
handler Application request handler.
timeout Read/write timeout configuration.
verbosity Logging verbosity (1 = requests, 2 = I/O errors).
tag Short protocol tag used in log lines.

microserve::detail::Http1Session::Http1Session(tcp::socket socket, const uint8_t* prefix, const std::size_t n, Handler& handler, Config::TimeoutConfig& timeout, const int verbosity, const std::string_view tag = "h11")

Construct a session that already has probe bytes buffered.

Parameters
socket Connected TCP socket, moved in.
prefix Bytes already read from the socket, or nullptr.
n Number of bytes in prefix.
handler Application request handler.
timeout Read/write timeout configuration.
verbosity Logging verbosity (1 = requests, 2 = I/O errors).
tag Short protocol tag used in log lines.

Used when HTTP/2 cleartext detection consumed a prefix that must be replayed as the start of the HTTP/1.1 request.