THttpResponse implements the mechanism for sending output to client users.
To output a string to client, use {@link write()}. By default, the output is
buffered until {@link flush()} is called or the application ends. The output in
the buffer can also be cleaned by {@link clear()}. To disable output buffering,
set BufferOutput property to false.
To send cookies to client, use {@link getCookies()}.
To redirect client browser to a new URL, use {@link redirect()}.
To send a file to client, use {@link writeFile()}.
By default, THttpResponse is registered with {@link TApplication} as the
response module. It can be accessed via {@link TApplication::getResponse()}.
THttpResponse may be configured in application configuration file as follows
where {@link getCacheExpire CacheExpire}, {@link getCacheControl CacheControl}
and {@link getBufferOutput BufferOutput} are optional properties of THttpResponse.
THttpResponse sends charset header if either {@link setCharset() Charset}
or {@link TGlobalization::setCharset() TGlobalization.Charset} is set.
Since 3.1.2, HTTP status code can be set with the {@link setStatusCode StatusCode} property.
Note: Some HTTP Status codes can require additional header or body information. So, if you use {@link setStatusCode StatusCode}
in your application, be sure to add theses informations.
E.g : to make an http authentication :
public function clickAuth ($sender, $param)
{
$response=$this->getResponse();
$response->setStatusCode(401);
$response->appendHeader('WWW-Authenticate: Basic realm="Test"');
}
This event handler will sent the 401 status code (Unauthorized) to the browser, with the WWW-Authenticate header field. This
will force the browser to ask for a username and a password.