|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Render a Unix epoch as an RFC 7231 IMF-fixdate. More...
Go to the source code of this file.
Macros | |
| #define | PC_HTTP_DATE_MAX 30 |
| Smallest buffer that holds an RFC 7231 IMF-fixdate plus its NUL. | |
Functions | |
| uint8_t | pc_http_date (time_t epoch, char *out, uint32_t out_cap) |
Write epoch into out as an IMF-fixdate in GMT. | |
Render a Unix epoch as an RFC 7231 IMF-fixdate.
One formatter serves every header that carries a timestamp (Date, Last-Modified, Expires), so the wire rendering is fixed in one place. The break-down is reentrant (gmtime_r, never the shared static tm), which is what makes it callable from any worker.
Every rejection - no epoch, no buffer, a time that will not break down - returns 0 and leaves out an empty string, so a caller that ignores the length still emits a well-formed header value rather than whatever the buffer held.
Definition in file http_date.h.
| #define PC_HTTP_DATE_MAX 30 |
Smallest buffer that holds an RFC 7231 IMF-fixdate plus its NUL.
Sun, 06 Nov 1994 08:49:37 GMT is 29 characters and the format is fixed-width, so this is a property of the protocol rather than a tuning choice. A smaller buffer truncates silently, because strftime writes nothing and returns 0 when the result does not fit.
Definition at line 35 of file http_date.h.
|
inline |
Write epoch into out as an IMF-fixdate in GMT.
out on any rejection. Definition at line 41 of file http_date.h.
References pc_gmtime_r().
Referenced by pc_ntp_http_date(), and pc_time_http_date().