ContentType
property ContentType: string read;
Example
procedure ScriptEvent(var Value: variant);
begin
if Request <> nil then
Value := Request.ContentType
else
Value := '';
end;
Usage
ContentType returns Velox's request media type after extracting the charset parameter into an unexposed separate field.
Additional Technical Info
ContentType returns Indy's TIdRequestHeaderInfo.ContentType, populated from the selected Content-Type request-header value. Indy's setter extracts/removes the charset parameter into a separate CharSet property before storing ContentType. Velox exposes ContentType but not that separate CharSet.
For example, a normal Content-Type: application/json; charset=utf-8 is ordinarily represented here as application/json, while another non-charset parameter can remain. This also means ContentString cannot see the extracted character set and normally uses UTF-8 fallback decoding even when the header declared something else.
The value is caller-supplied metadata, not validation of body bytes. Parse the media type and parameters according to HTTP syntax, compare type/subtype case-insensitively, define the endpoint's accepted types explicitly and reject unsupported input before parsing the body. Avoid broad substring tests that accept suffixes or parameter text unexpectedly.
ContentType does not decode ContentEncoding, choose a JSON/XML parser, enforce schema, detect malware or cap body size. An empty value means none was selected; decide whether the endpoint rejects missing media type rather than guessing from the data.
Test Request for nil and treat the live value as untrusted. The generic WebBroker page describes the abstraction; the Indy charset-extraction behavior above is the Velox runtime detail.
External references
Created 2026-07-15