Kaya 0.5.3 reference for HTMLDocument::addHTTPHeader

List of functions and data types in HTMLDocument

Void addHTTPHeader(HTMLDocument doc, String name, String value)

Arguments

Usage

Adds a HTTP header to the document. If the document is then printed using Webapp::displayPage, these headers will be sent to the client.

The effects of multiple HTTP headers with the same name vary. Some headers may be rewritten by the web server if they appear multiple times.

You can change the HTTP status code using the special Status header. The default is 200, of course - due to a bug in older versions of Apache, explicitly setting a 200 status is not recommended. Headers with names beginning "X-" are non-standard and could mean anything.

addHTTPHeader(doc,"Last-Modified",rfc2822Time(lmstamp));
addHTTPHeader(doc,"Status","404 File not found");
addHTTPHeader(doc,"X-Generator","Kaya");

The characters allowed in HTTP headers are relatively restricted, especially in the name field, the most obvious restriction being that they may not contain new lines. Webapp::displayPage will throw an Exception if illegal characters are found - be sure to check this if you write your own header output function.

RFC 2616 describes the HTTP protocol including HTTP headers in detail

You may set multiple headers with the same name, but this may not be sensible for some headers (for example, multiple Status headers make no sense, whereas multiple Set-Cookie headers are commonly used).

Related

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya