CGI.lua

Description

Download

CGI

log

function CGI:log()

name

string CGI:name()

path

string CGI:path()

print

function CGI:print()

request

Request CGI:request()

response

Response CGI:response()

run

self CGI:run( table someMappings )

version

string CGI:version()

Request

address

string CGI:request():address()

Returns the IP address of the client that sent the request. Same as the value of the CGI variable REMOTE_ADDR.

authentication

string CGI:request():authentication()

Returns the name of the authentication scheme. Same as the value of the CGI variable AUTH_TYPE.

contentLength

number CGI:request():contentLength()

Returns the length of the request content. Same as the value of the CGI variable CONTENT_LENGTH.

contentType

string CGI:request():contentType()

Returns the MIME type of the request. Same as the value of the CGI variable CONTENT_TYPE.

cookie

string CGI:request():cookie( string aKey )

cookies

table CGI:request():cookies()

header

string CGI:request():header( string aKey )

Returns the value of the specified request header as a string. If the request did not include a header of the specified name, this method returns nil. The header name is case insensitive.

method

string CGI:request():method()

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. Same as the value of the CGI variable REQUEST_METHOD.

parameter

string CGI:request():parameter( string aKey )

Returns the value of a request parameter as a string, or nil if the parameter does not exist. For HTTP, parameters are contained in the query string or posted form data.

parameters

table CGI:request():parameters()

url

URL CGI:request():url()

user

string CGI:request():user()

Returns the login of the user making this request. Same as the value of the CGI variable REMOTE_USER.

version

string CGI:request():version()

Returns the name and version of the protocol the request uses, for example, HTTP/1.1. Same as the value of the CGI variable SERVER_PROTOCOL.

URL

decode

string CGI:request():url():decode()

decodeParameters

table CGI:request():url():decodeParameters()

encode

string CGI:request():url():encode()

encodeParameters

string CGI:request():url():encodeParameters()

host

string CGI:request():url():host()

Returns the host name of the server that received the request. Same as the value of the CGI variable SERVER_NAME.

path

string CGI:request():url():path()

Returns the path of this request's URL. Same as the value of the CGI variable PATH_INFO.

port

number CGI:request():url():port()

Returns the port number on which this request was received. Same as the value of the CGI variable SERVER_PORT.

queries

table CGI:request():url():queries()

query

string CGI:request():url():query()

Returns the query string that is contained in the request URL after the path. Same as the value of the CGI variable QUERY_STRING.

scheme

string CGI:request():url():scheme()

Returns the name of the scheme used to make this request, for example, http, https, or ftp.

Response

contentType

string CGI:response():contentType()

setContentType

self CGI:response():setContentType()

cookie

string CGI:response():cookie( string aKey )

setCookie

self CGI:response():setCookie( string aKey, any aValue [, table someOptions ] )

cookies

table CGI:response():cookies()

encoding

string CGI:response():encoding()

Returns the name of the character encoding used in the body of this response. Defaults to UTF-8.

header

string CGI:response():header( string aKey )

setHeader

self CGI:response():setHeader( string aKey, any aValue )

headers

table CGI:response():headers()

server

string CGI:response():server()

status

number, string CGI:response():status()

setStatus

self CGI:response():setStatus( number aValue, string aDescription )

write

self CGI:response():write( string ... )

string

encode

string string.encode( string aValue )

License

Copyright © 2006 Raphaël Szwarc

This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.