Table of Contents

THttpServerRequest Class

Represents an incoming HTTP request received by a Sparkle server, exposing its method, URI, headers, and body content.

Remarks

Instances are created and populated by the server. The class distinguishes between the raw core data set by the transport (Method, RawUri, Headers, ContentStream) and helper read-only properties derived from it (MethodType, Uri, Content, and so on). The request body is read lazily: the underlying ContentStream is consumed only the first time Content is accessed.

Syntax

Unit: Sparkle.HttpServer.Request

THttpServerRequest = class(TObject);

Constructors

Name Description
Create Creates a new, empty request with an empty header collection and the default HTTP/1.1 protocol.

Properties

Name Description
Content Gets the full request body as a byte array.
ContentLength Gets the length of the request body as declared by the content-length header.
ContentStream Gets or sets the stream from which the request body is read.
ExtraInfo Gets or sets transport-specific extra information about the request, such as the remote IP.
Headers Gets the collection of request headers.
MajorVersion Gets the major version number of the request protocol.
Method Gets or sets the raw HTTP method string, for example GET or POST.
MethodType Gets the request method as a THttpMethod value parsed from Method.
MinorVersion Gets the minor version number of the request protocol.
OriginalUri Gets the parsed URI as originally received, before any rewriting, based on RawOriginalUri.
Protocol Gets or sets the request protocol string, for example HTTP/1.1. Defaults to HTTP/1.1.
RawOriginalUri Gets or sets the raw URI as originally received, before any rewriting.
RawUri Gets or sets the raw request URI as provided by the transport.
RemoteIp Gets the IP address of the remote client, if available.
Uri Gets the parsed URI of the request, based on the current RawUri.
User Gets or sets the authenticated user identity associated with the request.