12#if PC_ENABLE_HTTP_DELIVERY
14DeliveryVerdict pc_delivery_swr(uint32_t age_s, uint32_t max_age_s, uint32_t swr_s)
16 if (age_s <= max_age_s)
18 return DeliveryVerdict::DELIVERY_FRESH;
20 uint64_t window = (uint64_t)max_age_s + swr_s;
21 if ((uint64_t)age_s <= window)
23 return DeliveryVerdict::DELIVERY_STALE_REVALIDATE;
25 return DeliveryVerdict::DELIVERY_EXPIRED;
28size_t pc_delivery_cache_control(uint32_t max_age_s, uint32_t swr_s,
char *out,
size_t cap)
34 pc_sb b = {out, cap, 0,
true};
39 pc_sb_put(&b,
", stale-while-revalidate=");
50size_t pc_delivery_sw_manifest(
const char *
const *paths,
size_t n,
const char *version,
char *out,
size_t cap)
52 if (!out || cap == 0 || (n && !paths))
56 pc_sb b2 = {out, cap, 0,
true};
60 for (
size_t i = 0; i < n; i++)
HTTP delivery optimizations: stale-while-revalidate, Range/206 delta fetch, SW precache (PC_ENABLE_HT...
Bounded no-heap string builder that fails closed on overflow (one shared copy).
void pc_sb_json(pc_sb *b, const char *s)
Append s as a JSON string literal: double-quoted, with "</tt> and <tt>\</tt> backslash-escaped....
void pc_sb_put(pc_sb *b, const char *s)
Append NUL-terminated s; leaves the buffer untouched and clears ok if it would not fit.
void pc_sb_u32(pc_sb *b, uint32_t v)
Append v as decimal (no leading zeros; "0" for zero).
Bump-append target; ok latches false once an append would overflow cap.