- cgi:addheader(header, value)
- cgi:contentheader(type, subtype)
- cgi:htmlheader()
SYNOPSIS
DESCRIPTION
Functions that send HTTP headers back to the requesting client. The functions are only useful when processing the full request from a Lua script (.lua). For all other file types the header is sent automatically.
The header functions can only be called while the request is still in the header phase. Once sending of the actual response content has been started, attempting to send any more headers will make the client mistake the header as content. The header phase ends once cgi:write() has been called at least once.
The first form cgi:addheader() sends exactly one header line in the form:
The second form sends a full header for the content type as specified in type and subtype.
For example, the call cgi:contentheader("text", "plain") will send:
The form cgi:htmlheader() is a shortcut for cgi:contentheader("text", "html").
When it is desired to send extra headers, it is best to start with a call to cgi:htmlheader() or cgi:contentheader() and then topping it up with one or more calls to cgi:addheader().
Note that the function cgi:cookie() also sends a header line.