HTMLDocument.addHTTPHeader(3kaya)
NAME
HTMLDocument::addHTTPHeader - Adds a HTTP header to the document
SYNOPSIS
Void addHTTPHeader( HTMLDocument doc, String name, String value )
ARGUMENTS
doc The HTML document
name The name of the header
value The contents of the header
DESCRIPTION
Adds a HTTP header to the document. If the document is then printed
using Webapp.displayPage (3kaya) , 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 (3kaya) will throw an Exception if illegal characters are found - be sure to check this if you write your own header output function.- RFC 2616 <http://www.w3.org/Protocols/rfc2616/> 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).
AUTHORS
Kaya standard library by Edwin Brady, Chris Morris and others
(kaya@kayalang.org). For further information see http://kayalang.org/
LICENSE
The Kaya standard library is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License (version 2.1 or any later version) as published by the Free
Software Foundation.
RELATED
- HTMLDocument.HTMLDocument (3kaya) HTMLDocument.addHTTPHeader (3kaya) Webapp.displayPage (3kaya)