DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
DeterministicESPAsyncWebServer.cpp File Reference

Layer 7 (Application) — HTTP routing and request handler implementation. More...

#include "DeterministicESPAsyncWebServer.h"
#include <string.h>
#include <stdio.h>

Go to the source code of this file.

Detailed Description

Layer 7 (Application) — HTTP routing and request handler implementation.

Dispatch pipeline (called from DetWebServer::handle())

handle()
└─ server_tick() ← drain FreeRTOS event queue
└─ for each slot:
PARSE_COMPLETE → match_and_execute()
PARSE_ERROR → send(400)
PARSE_ENTITY_TOO_LARGE → send(413)
PARSE_URI_TOO_LONG → send(414)
@ PARSE_COMPLETE
Full request parsed; ready for dispatch.
Definition http_parser.h:63
@ PARSE_URI_TOO_LONG
Path exceeds MAX_PATH_LEN → 414.
Definition http_parser.h:66
@ PARSE_ENTITY_TOO_LARGE
Content-Length > BODY_BUF_SIZE → 413.
Definition http_parser.h:65
@ PARSE_ERROR
Unrecoverable parse failure → 400.
Definition http_parser.h:64
void server_tick()
Drive the session layer for one Arduino loop iteration.
Definition session.cpp:15

Route table Routes are stored in a fixed-size array of Route structs. Both exact and wildcard (suffix *) routes are supported; exact routes always take priority because the loop checks them in insertion order and returns on the first match.

PCB lifecycle in send() / send_empty() Before writing to the PCB the slot is set to CONN_FREE and the pcb pointer is nulled. This mirrors the pattern in transport.cpp:

  1. Save a local copy of the pcb pointer.
  2. Detach our slot from it (tcp_arg(pcb, nullptr)).
  3. Null out conn->pcb and set conn->state = CONN_FREE.
  4. Do the write + close/abort on the saved local pointer.

This means any lwIP error callback that fires mid-write sees the slot as already free and takes no action — preventing a double-free scenario.

Definition in file DeterministicESPAsyncWebServer.cpp.