Http2ClearTextImpl class final
#include <src/microserve/http2.cppm>
Clear-text HTTP/2 (h2c) and/or HTTP/1.1 backend.
Optionally probes the first bytes of each connection for the HTTP/2 client preface and dispatches to h2c or HTTP/1.1. Either protocol can be disabled via the constructor flags.
Base classes
- struct ServerImpl
- Abstract server backend.
Constructors, destructors, conversion operators
- Http2ClearTextImpl(net::io_context& ioc, const std::string& address, const unsigned short port, const int verbosity = 0, const bool allow_h2c = false, const bool allow_h11 = true)
- Construct a clear-text listener on
addressandport.
Public functions
- void set_handler(Handler h) override
- Install the request handler used by all accepted sessions.
- void start_server() override
- Start accepting connections on the configured endpoint.
- void stop_server() override
- Stop accepting connections and shut down active sessions.
Function documentation
microserve:: Http2ClearTextImpl:: Http2ClearTextImpl(net::io_context& ioc,
const std::string& address,
const unsigned short port,
const int verbosity = 0,
const bool allow_h2c = false,
const bool allow_h11 = true)
Construct a clear-text listener on address and port.
| Parameters | |
|---|---|
| ioc | Asio I/O context that drives the acceptor and sessions. |
| address | Bind address (for example "0.0.0.0" or "::"). |
| port | TCP port to listen on. |
| verbosity | Log verbosity (0 is quiet). |
| allow_h2c | When true, accept prior-knowledge HTTP/2 (h2c). |
| allow_h11 | When true, accept HTTP/1.1 requests. |
void microserve:: Http2ClearTextImpl:: set_handler(Handler h) override
Install the request handler used by all accepted sessions.
| Parameters | |
|---|---|
| h | Callback invoked for each incoming request. |
Must be called before start_