Table of Contents

TTMSMCPHTTPServerResponse Class

The answer to one request, which a handler fills in.

API unit family: TMS.MCP.HTTPServer Inherits from: TPersistent

Syntax

TTMSMCPHTTPServerResponse = class(TPersistent)

Remarks

Created and owned by the server and passed to the handler alongside the request; do not free it. A handler normally sets a status code, adds headers and assigns the body, and the server sends it once the handler returns. A handler that has to keep writing after it returns - to hold a stream open, for instance - sends the headers itself with TTMSMCPHTTPServerResponse.WriteHeader, clears TTMSMCPHTTPServerResponse.CloseConnection, and then writes through the connection object rather than through this response.

Properties

Name Description
CloseConnection Whether the connection is closed once the answer has been sent. Defaults to True.
ContentText The body of the answer. Empty by default.
HeaderHasBeenWritten Whether the headers have already been sent. False until they are.
Headers The headers to send with the answer.
ResponseCode Status code to answer with. 0 until the handler sets one.
ResponseText Reason phrase accompanying the status code. Empty by default.

Methods

Name Description
Redirect Answers with a redirect to another address.
WriteContent Sends the body now.
WriteHeader Sends the status line and the headers now, without waiting for the handler to return.