Table of Contents

THttpServerResponse Class

Represents the HTTP response being built for a request, exposing the status line, headers, and body content, and controlling how and when the response is sent to the client.

Remarks

Writing to Content sends the response headers automatically the first time body data is produced, after which header-related properties can no longer be changed. When neither ContentLength nor Chunked is set, Sparkle chooses chunked transfer for HTTP/1.1 or closes the connection after the body for HTTP/1.0. Call Close to finish the response.

Syntax

Unit: Sparkle.HttpServer.Response

THttpServerResponse = class(TObject);

Constructors

Name Description
Create Creates a new response with default settings: status not sent, keep-alive enabled, and HTTP/1.1 protocol.

Methods

Name Description
Close Overloaded
Close
Close(TBytes)
OnHeaders Registers a callback to be invoked immediately before the response headers are sent.

Properties

Name Description
Chunked Gets or sets whether the response body is sent using chunked transfer encoding.
Closed Indicates whether the response has been closed and can no longer be modified.
Content Gets the stream used to write the response body.
ContentEncoding Gets or sets the content-encoding response header.
ContentLength Gets or sets the response body length via the content-length header.
ContentType Gets or sets the content-type response header.
Headers Gets the collection of response headers.
HeadersSent Indicates whether the response headers have already been sent to the client.
MinChunkSize Gets or sets the minimum buffer size, in bytes, accumulated before a chunk is sent when using chunked encoding.
Protocol Gets or sets the response protocol string, for example HTTP/1.1. Defaults to HTTP/1.1.
RawWriter Gets or sets the writer responsible for sending the raw response body.
StatusCode Gets or sets the HTTP status code of the response.
StatusReason Gets or sets the reason phrase that accompanies the status code on the status line.