|
DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
|
Layer 7 (Application) - HTTP routing and request handler implementation. More...
#include "dwserver.h"#include "server/dwserver_internal.h"#include "network_drivers/presentation/presentation.h"#include "network_drivers/session/proto_handler.h"#include "network_drivers/session/worker.h"#include "network_drivers/tls/tls.h"#include "network_drivers/transport/listener.h"#include "shared_primitives/hex.h"#include "shared_primitives/mime.h"#include <stdarg.h>#include <stdio.h>#include <string.h>Go to the source code of this file.
Classes | |
| struct | InstanceCtx |
Functions | |
| const char * | status_text (int code) |
| Convert an HTTP status code to its standard reason phrase. | |
| void | fill_route_base (Route *r, const char *path) |
| Register a route in the route table. | |
| bool | req_is_head (uint8_t slot_id) |
True if the request in slot slot_id used the HEAD method (send headers, no body). | |
Variables | |
| SendCtx | s_send |
Layer 7 (Application) - HTTP routing and request handler implementation.
Dispatch pipeline (called from DetWebServer::handle())
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 / teardown ownership All TCP I/O and teardown go through the transport-layer connection API (det_conn_send / det_conn_flush / det_conn_begin_close / det_conn_close / det_conn_abort_slot), so this layer never calls lwIP or touches the raw tcp_pcb directly. The transport owns the teardown order for every close: it detaches the pcb from its lwIP callbacks and sets the slot ConnState::CONN_FREE (pcb nulled) BEFORE the FIN/RST, on the captured pcb pointer. This means any lwIP error callback that fires mid-teardown sees the slot as already free and takes no action - preventing a double-free. L7 passes only the slot index: det_conn_close(slot) for a graceful local close, det_conn_abort_slot(slot) for a hard RST, det_conn_begin_close(slot) for the drain-then-close dwell.
Definition in file dwserver.cpp.
| const char * status_text | ( | int | code | ) |
Convert an HTTP status code to its standard reason phrase.
Reason phrase for an HTTP status code (e.g. 404 -> "Not Found").
Covers the 18 codes that arise in typical REST micro-server usage. Unknown codes produce "Unknown" so callers never receive a null pointer.
| code | HTTP status integer. |
Definition at line 112 of file dwserver.cpp.
Referenced by DetWebServer::redirect(), DetWebServer::send(), DetWebServer::send_chunked(), DetWebServer::send_empty(), and DetWebServer::send_template().
| void fill_route_base | ( | Route * | r, |
| const char * | path | ||
| ) |
Register a route in the route table.
Initialize the common fields (path, flags) of a route-table entry from its pattern.
Paths are stored null-terminated and truncated to MAX_PATH_LEN. The trailing character of the stored path is inspected to detect wildcard routes: any path ending in * is treated as a prefix match.
Registrations beyond MAX_ROUTES are silently ignored - callers should verify return values if overflow is a concern.
| path | URL path to match, e.g. "/api/*". |
| method | HTTP method that triggers this route. |
| callback | Handler invoked with (slot_id, request). |
Definition at line 747 of file dwserver.cpp.
References DETIFACE_ANY, Route::iface_filter, Route::is_active, Route::is_param, Route::is_regex, Route::is_wildcard, MAX_PATH_LEN, and Route::path.
Referenced by DetWebServer::on(), DetWebServer::on(), and DetWebServer::on_regex().
| bool req_is_head | ( | uint8_t | slot_id | ) |
True if the request in slot slot_id used the HEAD method (send headers, no body).
Definition at line 1228 of file dwserver.cpp.
References http_pool.
Referenced by DetWebServer::send(), DetWebServer::send_chunked(), and DetWebServer::send_template().
| SendCtx s_send |
Definition at line 97 of file dwserver.cpp.
Referenced by DetWebServer::http_poll_slot(), and DetWebServer::send_chunked().