Kitto.Web.Response
Response wrappers for KittoX. TKWebResponse adapts a WebBroker TWebResponse (status, headers, cookies, content stream) and owns a stack of TKWebResponseContent buffers that accumulate the HTML/HTMX output before it is flushed to the client. The active response is kept thread-local.
TKWebResponseContent class
Simplified response content container for KittoX (HTMX). Replaces the former TJSResponseItems which contained the full ExtJS JS generation pipeline.
procedure Clear;Removes all accumulated HTML.
procedure AddHTML(const AHTML: string);Appends an HTML fragment to the content.
function Consume: string;Returns the full accumulated HTML and clears the buffer.
function GetContentType: string;The content type for this HTML content ('text/html; charset=…').
property Charset: string read FCharset write FCharset;The character set used for the content (default utf-8).
property Encoding: TEncoding read GetEncoding;The text encoding matching Charset.
property Count: Integer read GetCount;Number of HTML fragments accumulated.
TKWebResponse class
Wraps a WebBroker TWebResponse and is used throughout KittoX whenever a response object is needed. Exposes status code, content type, custom headers and cookies, and an Items stack of HTML content buffers that Send flushes to the underlying response.
class procedure ClearCurrent;Frees and clears the current-thread response.
constructor Create(const AResponse: TWebResponse;Wraps the given WebBroker response (optionally taking ownership).
property ContentType: string read GetContentType write SetContentType;The response Content-Type header.
property StatusCode: Integer read GetStatusCode write SetStatusCode;The HTTP status code.
procedure SetCustomHeader(const AName, AValue: string);Sets (or replaces) a custom response header.
property CustomHeaders: TStrings read GetCustomHeaders;The custom response headers collection.
procedure SetCookie(const AName, AValue: string;Writes a simple cookie (name/value/expiry).
procedure SetSecureCookie(const AName, AValue: string;Writes a cookie with the full set of attributes needed by JWT auth: Path, HttpOnly, Secure, SameSite. Pass an empty path to use '/'. ASameSite values: 'Strict' | 'Lax' | 'None' | '' (omit attribute).
function HasItems: Boolean;True if any HTML content has been accumulated in Items.
property Items: TKWebResponseContent read GetItems;The top HTML content buffer (the HTMX/HTML output pipeline).
procedure Send;Generates content for all the Items and sets Content/ContentStream and ContentType accordingly. Then finalizes the response. Called as a final act after all request handlers have had a chance at contributing to it.
procedure ReplaceContentStream(const AStream: TStream);Takes care of freeing a previous content stream, if any, before assigning a new one.
