HttpSendStream
function HttpSendStream(const aRequest: iHttpRequest; const aResponse: iHttpResponse; aStream: TStream; aOwns: Boolean; const aContentType: string; const aValidators: tHttpValidators; const aCacheControl: string = ''): Integer;
THE ONE TO CALL FOR ANYTHING STATIC. Validators, conditional requests and byte ranges over a stream the caller holds, then HttpSendStreamRange for the body. RFC 9110 section 13 in the order it prescribes:
If-None-Match weak comparison against ETag; '*' matches. False => 304 (GET/HEAD) or 412 (anything else), and If-Modified-Since is then not looked at. If-Modified-Since GET/HEAD only, only when there is no If-None-Match, only when LastModified is known and the field parses. Not modified since => 304.
If-Range only when Range is present. An entity-tag matches under STRONG comparison (a weak tag on either side never does); a date matches only if it equals Last-Modified to the second. No match, or nothing to compare against => the Range is ignored and the whole representation is sent (200).
A 304 carries ETag, Last-Modified and Accept-Ranges and an empty body, as the 200 it stands in for would have. Both validators go on every 200 and 206 when known. aStream is freed on every path when aOwns is True. Answers the status it set. Nothing conditional happens without validators - pass HttpStreamValidators(aStream) for a file, or your own for anything else.
aCacheControl IS THE CALLER'S POLICY, sent verbatim as Cache-Control on 200, 206 and 304 (RFC 9111 section 4.3.4: a 304 must carry what the 200 would) and not sent at all when ''. The library has no opinion on how long your content may be cached; the constants below are the usual answers, and the validators are what make any of them cheap - a cache that has expired revalidates with If-None-Match and gets a bodiless 304 back.