DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
h2_server.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file h2_server.h
6 * @brief Bridge between the HTTP/2 engine (h2_conn) and the server's request pipeline.
7 *
8 * When a TLS connection negotiates ALPN "h2", the session layer hands its decrypted bytes to
9 * this module instead of the HTTP/1.1 parser. It runs one h2_conn per connection slot, maps each
10 * decoded request's pseudo-headers (:method / :path / :authority) and headers into the slot's
11 * HttpReq, and marks it ParseState::PARSE_COMPLETE so the existing route dispatcher serves it. Responses from
12 * the handlers route back here (DetWebServer::send branches on the slot's h2 flag) and are
13 * serialized as HEADERS + DATA frames, leaving the connection open for the next stream.
14 *
15 * The per-slot engines are large (a whole frame is buffered), so their pool lives in PSRAM where
16 * available; HTTP/2 is therefore practical on PSRAM boards (ESP32-S3/-P4, WROVER).
17 *
18 * @author Douglas Quigg (dstroy0)
19 * @date 2026
20 */
21
22#ifndef DETERMINISTICESPASYNCWEBSERVER_H2_SERVER_H
23#define DETERMINISTICESPASYNCWEBSERVER_H2_SERVER_H
24
25#include "ServerConfig.h"
26
27#if DETWS_ENABLE_HTTP2 && DETWS_ENABLE_TLS
28
29#include <stddef.h>
30#include <stdint.h>
31
32/** @brief Start the HTTP/2 engine for @p slot after ALPN "h2" (sends our initial SETTINGS). */
33void h2_server_open(uint8_t slot);
34
35/** @brief Feed the slot's decrypted inbound bytes into the engine; drives requests via HttpReq. */
36void h2_server_data(uint8_t slot);
37
38/**
39 * @brief Serialize a handler's response for the slot's current stream (HEADERS + DATA), then ready
40 * the slot's HttpReq for the next stream (the connection stays open). @return false on error.
41 */
42bool h2_server_respond(uint8_t slot, int code, const char *content_type, const char *body, size_t len);
43
44/** @brief Release per-slot HTTP/2 state on connection close. */
45void h2_server_close(uint8_t slot);
46
47#endif // DETWS_ENABLE_HTTP2 && DETWS_ENABLE_TLS
48#endif // DETERMINISTICESPASYNCWEBSERVER_H2_SERVER_H
User-facing configuration for DeterministicESPAsyncWebServer.