| LUA-URI-_LOGIN(3) | Lua uri._login module | LUA-URI-_LOGIN(3) |
lua-uri-_login - Lua URI library support for URIs containing usernames and passwords
The "uri._login" class is used as a base class by classes implementing URI schemes which can have a username and password in the userinfo part, separated by a colon.
A URI of this type where the userinfo part contains more than one colon is considered invalid. They must also have a non-empty host part. The username and password are each optional.
The current implementation requires subclasses to call this class's "init_base" method within their "init" method to do the extra validation. This may change if I think of a better way of doing it.
All the methods defined in lua-uri(3) are supported, in addition to the following:
local uri = assert(URI:new("ftp://host/path"))
uri:username("fred") -- ftp://fred@host/path
uri:username(nil) -- ftp://host/path
Passing nil as the new username will also remove any password in the userinfo, since the password is expected to be meaningless without the username.
The username is appropriately percent encoded and decoded by this method.
The password is appropriately percent encoded and decoded by this method.
local password = uri:password()
uri:password("secret")
The main RFC for URIs ("RFC 3986") does not specify a syntax for the userinfo part of the authority, which is why the "username" and "password" methods are not provided in the generic "uri" class. The use of the colon to separate these parts, and the escaping conventions, are instead derived from the older "RFC 1738 section 3.1", and the up to date telnet URI specification in "RFC 4248".
| 2012-00-00 | 1.1 |