![]() |
CGILua 5.0 |
Server API |
The Server API is a set of functions that encapsulate the web server and the used launcher. The functions are grouped into two groups: SAPI.Request and SAPI.Response.
The Server API allows the abstraction of a series of details and makes CGILua a lot more portable, since porting it means writing a SAPI Launcher for the target platform.
CGILua currently supports Apache, Microsoft IIS, Tomcat and Xavante as web servers, and CGI, FastCGI, mod_lua, ISAPI and Servlets as Launchers.
Here is the list of SAPI functions:
SAPI.Response.contenttype (string)
Sends
the Content-type
header to the client. The given
string is of the form "type/subtype". This function must be called
before any output is generated.SAPI.Response.redirect (string)
Sends the
Location
header to the client. The given string should
be a URL.SAPI.Response.header (header, value)
Sends
a generic header to the client. The first argument must be the
header name, such as "Set-Cookie". The second argument should be
its value. This function should not be used to replace the
contenttype
nor the redirect
functions.SAPI.Response.write (string)
Generates
output.SAPI.Response.errorlog (string)
Generates
error output.SAPI.Request.getpostdata ([n])
Gets a block
of "POST data". The optional parameter is the number of bytes to
read (a default block size is used instead). This function returns
the block as a Lua string.SAPI.Request.servervariable (string)
Gets
the value of an environment variable (CONTENT_LENGTH
,
QUERY_STRING
, REMOTE_ADDR
etc.). The
argument must be a CGI variable.