DeterministicESPAsyncWebServer v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
dwserver_internal.h File Reference

Library-private declarations shared between dwserver.cpp and the src/server/*.cpp request-handler translation units it is split into (WebDAV, file serving, ...). More...

#include "dwserver.h"
#include <time.h>

Go to the source code of this file.

Classes

struct  ChunkSend
 
struct  SendCtx
 

Functions

const char * status_text (int code)
 Reason phrase for an HTTP status code (e.g. 404 -> "Not Found").
 
void fill_route_base (Route *r, const char *path)
 Initialize the common fields (path, flags) of a route-table entry from its pattern.
 
void http_rfc1123 (time_t t, char *out, size_t cap)
 Format t as an RFC 1123 GMT date into out (cap bytes); out is emptied for t <= 0.
 
bool req_is_head (uint8_t slot_id)
 True if the request in slot slot_id used the HEAD method (send headers, no body).
 
bool regex_match (const char *pattern, const char *path)
 Whole-path regex match (anchored both ends; bounded by RE_MAX_STEPS, fails closed). Defined in server/regex.cpp, called by the route dispatcher for on_regex() routes.
 

Variables

SendCtx s_send
 

Detailed Description

Library-private declarations shared between dwserver.cpp and the src/server/*.cpp request-handler translation units it is split into (WebDAV, file serving, ...).

These are NOT part of the public API - they are the handful of dwserver.cpp file-scope helpers that a split-out handler still needs, promoted from static to external linkage so the pieces link together. Everything else a handler needs is either a public DetWebServer method (declared in dwserver.h) or already an extern in the transport headers (e.g. conn_pool in tcp.h).

Definition in file dwserver_internal.h.

Function Documentation

◆ status_text()

const char * status_text ( int  code)

Reason phrase for an HTTP status code (e.g. 404 -> "Not Found").

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.

Parameters
codeHTTP status integer.
Returns
Pointer to a string-literal reason phrase; never null.

Definition at line 112 of file dwserver.cpp.

Referenced by DetWebServer::redirect(), DetWebServer::send(), DetWebServer::send_chunked(), DetWebServer::send_empty(), and DetWebServer::send_template().

◆ fill_route_base()

void fill_route_base ( Route r,
const char *  path 
)

Initialize the common fields (path, flags) of a route-table entry from its pattern.

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.

Parameters
pathURL path to match, e.g. "/api/*".
methodHTTP method that triggers this route.
callbackHandler 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().

◆ http_rfc1123()

void http_rfc1123 ( time_t  t,
char *  out,
size_t  cap 
)

Format t as an RFC 1123 GMT date into out (cap bytes); out is emptied for t <= 0.

◆ req_is_head()

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().

◆ regex_match()

bool regex_match ( const char *  pattern,
const char *  path 
)

Whole-path regex match (anchored both ends; bounded by RE_MAX_STEPS, fails closed). Defined in server/regex.cpp, called by the route dispatcher for on_regex() routes.

Definition at line 188 of file regex.cpp.

References ReCtx::max_steps, RE_MAX_STEPS, and ReCtx::steps.

Variable Documentation

◆ s_send

SendCtx s_send
extern

Definition at line 97 of file dwserver.cpp.

Referenced by DetWebServer::http_poll_slot(), and DetWebServer::send_chunked().