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

Format a Unix epoch as an RFC 7231 IMF-fixdate (one shared copy). More...

#include <stddef.h>
#include <stdint.h>
#include <time.h>

Go to the source code of this file.

Functions

size_t detws_http_date (time_t epoch, char *out, size_t out_cap)
 Write epoch as an RFC 7231 IMF-fixdate into out (always GMT).
 

Detailed Description

Format a Unix epoch as an RFC 7231 IMF-fixdate (one shared copy).

The Date: header formatter (gmtime_r + strftime to "%a, %d %b %Y %H:%M:%S GMT") was open-coded in the NTP service; the time-source-fed Date header needs the same thing. This header-only inline helper is the single home for it - reentrant (gmtime_r, never the shared static tm buffer, so it is worker-safe) and fail-closed (empty string, length 0) when the epoch is unset or does not fit a broken-down year.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file http_date.h.

Function Documentation

◆ detws_http_date()

size_t detws_http_date ( time_t  epoch,
char *  out,
size_t  out_cap 
)
inline

Write epoch as an RFC 7231 IMF-fixdate into out (always GMT).

Returns
bytes written (excluding the NUL), or 0 with an empty out when epoch is 0, out is null / out_cap is 0, or the time cannot be broken down.

Definition at line 30 of file http_date.h.

Referenced by detws_ntp_http_date(), and detws_time_http_date().