includes/Edge/class-header-emitter.php
Header emitter — single consolidation point for dynamic header() emission.
Class Header_Emitter
Class Header_Emitter
final class Header_Emitterpublicstatic strip_crlf()
public static function strip_crlf(string $value): stringStrip CR/LF (and NUL) bytes from a value before it is passed to header(). Parameter Type Default Description $valuestring— Header value to clean.
Return: string — Value without header-breaking control characters.
publicstatic emit()
public static function emit(string $header, bool=true $replace): boolEmit a single header line (CRLF-safe, headers_sent-guarded). Parameter Type Default Description $headerstring— Full header line (e.g. \’X-LiteSpeed-Tag: WPPO\’). $replacebool=true— Whether to replace a previous similar header.
Return: bool — True when emitted, false when headers were already sent.
publicstatic emit_private_pair()
public static function emit_private_pair(): voidEmit the ESI private pair (Cache-Control + X-LiteSpeed-Cache-Control).
Return: void.
publicstatic emit_nocache_pair()
public static function emit_nocache_pair(): voidEmit the ESI no-cache pair (Cache-Control + X-LiteSpeed-Cache-Control).
Return: void.
publicstatic emit_purge_tag()
public static function emit_purge_tag(string $tag_str): boolEmit an X-LiteSpeed-Purge tag header (CRLF-safe). Parameter Type Default Description $tag_strstring— Comma-separated tag list (unsanitized).
Return: bool — True when emitted, false when headers were already sent.
publicstatic emit_tag()
public static function emit_tag(string $tag): boolEmit an X-LiteSpeed-Tag header (CRLF-safe). Parameter Type Default Description $tagstring— Single tag value (unsanitized).
Return: bool — True when emitted, false when headers were already sent.
publicstatic emit_esi_tag()
public static function emit_esi_tag(string $action): boolEmit an ESI tag header (X-LiteSpeed-Tag: ESI.{action}). Parameter Type Default Description $actionstring— ESI action name (unsanitized).
Return: bool — True when emitted, false when headers were already sent.
publicstatic remove_generic_cache_control()
public static function remove_generic_cache_control(): voidRemove generic Cache-Control/Pragma when the LiteSpeed public header is sent.
Return: void.
publicstatic sanitize_tag()
public static function sanitize_tag(string $tag): stringAllowlist a LiteSpeed tag value to the safe header charset. Parameter Type Default Description $tagstring— Raw tag value.
Return: string — Sanitized tag value.