HTTP
HTTP (Hyper Text Transfer Protocol) is the protocol used to exchange information between web-browsers and servers. The http namespace offers full support for the client side of the HTTP protocol (i.e., the facilities that would be used by a web-browser implementation). The implementation conforms to the HTTP/1.1 standard, RFC 2616.
The module exports functions that provide HTTP functionality in different levels of abstraction. From the simple string oriented requests, through generic LTN12 based, down to even lower-level if you bother to look through the source code.
To obtain the http namespace, run:
-- loads the HTTP module and any libraries it requires
local http = require("socket.http")
URLs must conform to RFC 1738, that is, an URL is a string in the form:
[http://][[:]@][:][/
MIME headers are represented as a Lua table in the form:
headers = {
field-1-name = field-1-value,
field-2-name = field-2-value,
field-3-name = field-3-value,
...
field-n-name = field-n-value
}
Field names are case insensitive (as specified by the standard) and all functions work with lowercase field names. Field values are left unmodified.
Note: MIME headers are independent of order. Therefore, there is no problem in representing them in a Lua table.
The following constants can be set to control the default behavior of the HTTP module:
PORT: default port used for connections;
PROXY: default proxy used for connections;
TIMEOUT: sets the timeout for all I/O operations;
USERAGENT: