Compare commits

...

5 Commits

Author SHA1 Message Date
Caleb Maclennan
24528134fd
Merge b281e6f717 into 93eef5015e 2024-03-20 04:28:20 -06:00
Thijs Schreijer
93eef5015e
chore(docs): update LTN12 links (#428) 2024-03-15 12:55:02 +01:00
Caleb Maclennan
b281e6f717
docs: Remove params documentation 2023-11-09 14:40:15 +03:00
Caleb Maclennan
784b0631e1
test(url): Update URL parsing expectations for params removal 2023-11-09 14:40:15 +03:00
Caleb Maclennan
a1b5d3abd1
chore(url)!: Remove params parsing, part of deprecated URL schema 2023-11-09 14:40:15 +03:00
9 changed files with 51 additions and 90 deletions

View File

@ -55,7 +55,7 @@ protocol. For that, check the implementation.
<p>
To really benefit from this module, a good understanding of
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">
LTN012, Filters sources and sinks</a> is necessary.
</p>
@ -122,7 +122,7 @@ expects at least the fields <tt>host</tt>, <tt>sink</tt>, and one of
<tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes
precedence). <tt>Host</tt> is the server to connect to. <tt>Sink</tt> is
the <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
sink that will receive the downloaded data. <tt>Argument</tt> or
<tt>path</tt> give the target path to the resource in the server. The
optional arguments are the following:
@ -136,7 +136,7 @@ authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>";</li>
<li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or
"<tt>a</tt>". Defaults to whatever is the server default;</li>
<li><tt>step</tt>:
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
pump step function used to pass data from the
server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function;</li>
<li><tt>create</tt>: An optional function to be used instead of
@ -206,7 +206,7 @@ expects at least the fields <tt>host</tt>, <tt>source</tt>, and one of
<tt>argument</tt> or <tt>path</tt> (<tt>argument</tt> takes
precedence). <tt>Host</tt> is the server to connect to. <tt>Source</tt> is
the <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
source that will provide the contents to be uploaded.
<tt>Argument</tt> or
<tt>path</tt> give the target path to the resource in the server. The
@ -221,7 +221,7 @@ authentication. Defaults to "<tt>ftp:anonymous@anonymous.org</tt>";</li>
<li><tt>type</tt>: The transfer mode. Can take values "<tt>i</tt>" or
"<tt>a</tt>". Defaults to whatever is the server default;</li>
<li><tt>step</tt>:
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
pump step function used to pass data from the
server to the sink. Defaults to the LTN12 <tt>pump.step</tt> function;</li>
<li><tt>create</tt>: An optional function to be used instead of

View File

@ -52,7 +52,7 @@ implementation conforms to the HTTP/1.1 standard,
The module exports functions that provide HTTP functionality in different
levels of abstraction. From the simple
string oriented requests, through generic
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> based, down to even lower-level if you bother to look through the source code.
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a> based, down to even lower-level if you bother to look through the source code.
</p>
<p>
@ -144,7 +144,7 @@ http.<b>request{</b><br>
The request function has two forms. The simple form downloads
a URL using the <tt>GET</tt> or <tt>POST</tt> method and is based
on strings. The generic form performs any HTTP method and is
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> based.
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a> based.
</p>
<p class="parameters">
@ -158,7 +158,7 @@ in the <tt>url</tt>. Otherwise, it performs a <tt>GET</tt> in the
<p class="parameters">
If the first argument is instead a table, the most important fields are
the <tt>url</tt> and the <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
<tt>sink</tt> that will receive the downloaded content.
Any part of the <tt>url</tt> can be overridden by including
the appropriate field in the request table.
@ -172,13 +172,13 @@ following:
<li><tt>method</tt>: The HTTP request method. Defaults to "GET";</li>
<li><tt>headers</tt>: Any additional HTTP headers to send with the request;</li>
<li><tt>source</tt>: <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
source to provide the request body. If there
is a body, you need to provide an appropriate "<tt>content-length</tt>"
request header field, or the function will attempt to send the body as
"<tt>chunked</tt>" (something few servers support). Defaults to the empty source;</li>
<li><tt>step</tt>:
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
pump step function used to move data.
Defaults to the LTN12 <tt>pump.step</tt> function.</li>
<li><tt>proxy</tt>: The URL of a proxy server to use. Defaults to no proxy;</li>

View File

@ -54,7 +54,7 @@ MIME is described mainly in
<p>
All functionality provided by the MIME module
follows the ideas presented in
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">
LTN012, Filters sources and sinks</a>.
</p>

View File

@ -57,7 +57,7 @@ of the MIME standard, but described mainly
in <a href="http://www.ietf.org/rfc/rfc2046.txt">RFC 2046</a>.</p>
<p> In the description below, good understanding of <a
href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> LTN012, Filters
href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md"> LTN012, Filters
sources and sinks</a> and the <a href="mime.html">MIME</a> module is
assumed. In fact, the SMTP module was the main reason for their
creation. </p>
@ -122,7 +122,7 @@ smtp.<b>message(</b>mesgt<b>)</b>
<p class="description">
Returns a <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep).
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a> source that sends an SMTP message body, possibly multipart (arbitrarily deep).
</p>
<p class="parameters">
@ -155,7 +155,7 @@ multipart-mesgt = {<br>
For a simple message, all that is needed is a set of <tt>headers</tt>
and the <tt>body</tt>. The message <tt>body</tt> can be given as a string
or as a <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
source. For multipart messages, the body is a table that
recursively defines each part as an independent message, plus an optional
<tt>preamble</tt> and <tt>epilogue</tt>.
@ -163,7 +163,7 @@ recursively defines each part as an independent message, plus an optional
<p class="return">
The function returns a <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
source that produces the
message contents as defined by <tt>mesgt</tt>, chunk by chunk.
Hopefully, the following
@ -264,7 +264,7 @@ The sender is given by the e-mail address in the <tt>from</tt> field.
address, or a string
in case there is just one recipient.
The contents of the message are given by a <em>simple</em>
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
<tt>source</tt>. Several arguments are optional:
</p>
<ul>
@ -276,7 +276,7 @@ methods if supported by the server (both are unsafe);</li>
<li> <tt>domain</tt>: Domain name used to greet the server; Defaults to the
local machine host name;</li>
<li> <tt>step</tt>:
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
pump step function used to pass data from the
source to the server. Defaults to the LTN12 <tt>pump.step</tt> function;</li>
<li><tt>create</tt>: An optional function to be used instead of
@ -308,7 +308,7 @@ Only recipients specified in the <tt>rcpt</tt> list will receive a copy of the
message. Each recipient of an SMTP mail message receives a copy of the
message body along with the headers, and nothing more. The headers
<em>are</em> part of the message and should be produced by the
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
<tt>source</tt> function. The <tt>rcpt</tt> list is <em>not</em>
part of the message and will not be sent to anyone.
</p>

View File

@ -311,7 +311,7 @@ socket.<b>sink(</b>mode, socket<b>)</b>
<p class="description">
Creates an
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
sink from a stream socket object.
</p>
@ -386,7 +386,7 @@ socket.<b>source(</b>mode, socket [, length]<b>)</b>
<p class="description">
Creates an
<a href="http://lua-users.org/wiki/FiltersSourcesAndSinks">LTN12</a>
<a href="https://github.com/lunarmodules/luasocket/blob/master/ltn012.md">LTN12</a>
source from a stream socket object.
</p>

View File

@ -60,7 +60,7 @@ An URL is defined by the following grammar:
<blockquote>
<tt>
&lt;url&gt; ::= [&lt;scheme&gt;:][//&lt;authority&gt;][/&lt;path&gt;][;&lt;params&gt;][?&lt;query&gt;][#&lt;fragment&gt;]<br>
&lt;url&gt; ::= [&lt;scheme&gt;:][//&lt;authority&gt;][/&lt;path&gt;][?&lt;query&gt;][#&lt;fragment&gt;]<br>
&lt;authority&gt; ::= [&lt;userinfo&gt;@]&lt;host&gt;[:&lt;port&gt;]<br>
&lt;userinfo&gt; ::= &lt;user&gt;[:&lt;password&gt;]<br>
&lt;path&gt; ::= {&lt;segment&gt;/}&lt;segment&gt;<br>
@ -225,7 +225,6 @@ parsed_url = {<br>
&nbsp;&nbsp;scheme = <i>string</i>,<br>
&nbsp;&nbsp;authority = <i>string</i>,<br>
&nbsp;&nbsp;path = <i>string</i>,<br>
&nbsp;&nbsp;params = <i>string</i>,<br>
&nbsp;&nbsp;query = <i>string</i>,<br>
&nbsp;&nbsp;fragment = <i>string</i>,<br>
&nbsp;&nbsp;userinfo = <i>string</i>,<br>
@ -255,7 +254,6 @@ parsed_url = url.parse("ftp://root:passwd@unsafe.org/pub/virus.exe;type=i")
-- scheme = "ftp",
-- authority = "root:passwd@unsafe.org",
-- path = "/pub/virus.exe",
-- params = "type=i",
-- userinfo = "root:passwd",
-- host = "unsafe.org",
-- user = "root",

View File

@ -207,7 +207,6 @@ local function adjusturi(reqt)
if not reqt.proxy and not _M.PROXY then
u = {
path = socket.try(reqt.path, "invalid path 'nil'"),
params = reqt.params,
query = reqt.query,
fragment = reqt.fragment
}

View File

@ -125,7 +125,7 @@ end
-----------------------------------------------------------------------------
-- Parses a url and returns a table with all its parts according to RFC 2396
-- The following grammar describes the names given to the URL parts
-- <url> ::= <scheme>://<authority>/<path>;<params>?<query>#<fragment>
-- <url> ::= <scheme>://<authority>/<path>?<query>#<fragment>
-- <authority> ::= <userinfo>@<host>:<port>
-- <userinfo> ::= <user>[:<password>]
-- <path> :: = {<segment>/}<segment>
@ -136,7 +136,7 @@ end
-- table with the following fields, where RFC naming conventions have
-- been preserved:
-- scheme, authority, userinfo, user, password, host, port,
-- path, params, query, fragment
-- path, query, fragment
-- Obs:
-- the leading '/' in {/<path>} is considered part of <path>
-----------------------------------------------------------------------------
@ -166,11 +166,6 @@ function _M.parse(url, default)
parsed.query = q
return ""
end)
-- get params
url = string.gsub(url, "%;(.*)", function(p)
parsed.params = p
return ""
end)
-- path is whatever was left
if url ~= "" then parsed.path = url end
local authority = parsed.authority
@ -203,7 +198,6 @@ function _M.build(parsed)
--local ppath = _M.parse_path(parsed.path or "")
--local url = _M.build_path(ppath)
local url = parsed.path or ""
if parsed.params then url = url .. ";" .. parsed.params end
if parsed.query then url = url .. "?" .. parsed.query end
local authority = parsed.authority
if parsed.host then
@ -258,11 +252,8 @@ function _M.absolute(base_url, relative_url)
relative_parsed.authority = base_parsed.authority
if not relative_parsed.path then
relative_parsed.path = base_parsed.path
if not relative_parsed.params then
relative_parsed.params = base_parsed.params
if not relative_parsed.query then
relative_parsed.query = base_parsed.query
end
if not relative_parsed.query then
relative_parsed.query = base_parsed.query
end
else
relative_parsed.path = absolute_path(base_parsed.path or "",

View File

@ -99,8 +99,7 @@ check_parse_url{
userinfo = "user:pass$%?#wd",
password = "pass$%?#wd",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -113,8 +112,7 @@ check_parse_url{
userinfo = "user:pass?#wd",
password = "pass?#wd",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -127,8 +125,7 @@ check_parse_url{
userinfo = "user:pass-wd",
password = "pass-wd",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -141,8 +138,7 @@ check_parse_url{
userinfo = "user:pass#wd",
password = "pass#wd",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -155,8 +151,7 @@ check_parse_url{
userinfo = "user:pass#wd",
password = "pass#wd",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
}
check_parse_url{
@ -167,8 +162,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -182,8 +176,7 @@ check_parse_url{
userinfo = "user:password",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment",
}
@ -196,8 +189,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = ""
}
@ -210,8 +202,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "",
fragment = "fragment"
}
@ -224,8 +215,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
fragment = "fragment"
}
@ -237,8 +227,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "",
path = "/path;",
query = "query",
fragment = "fragment"
}
@ -264,8 +253,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/",
params = "params",
path = "/;params",
query = "query",
fragment = "fragment"
}
@ -287,8 +275,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -438,8 +425,7 @@ check_parse_url{
port = "port",
userinfo = "userinfo",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -453,8 +439,7 @@ check_parse_url{
userinfo = "user:password",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -467,8 +452,7 @@ check_build_url {
port = "port",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -478,8 +462,7 @@ check_build_url{
host = "::FFFF:129.144.52.38",
port = "port",
user = "userinfo",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -491,8 +474,7 @@ check_build_url{
port = "port",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -503,8 +485,7 @@ check_build_url {
host = "host",
user = "user",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -514,8 +495,7 @@ check_build_url {
scheme = "scheme",
host = "host",
user = "user",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -524,8 +504,7 @@ check_build_url {
url = "scheme://host/path;params?query#fragment",
scheme = "scheme",
host = "host",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -534,8 +513,7 @@ check_build_url {
url = "scheme://host/path;params#fragment",
scheme = "scheme",
host = "host",
path = "/path",
params = "params",
path = "/path;params",
fragment = "fragment"
}
@ -573,9 +551,7 @@ check_build_url {
user = "user",
userinfo = "not used",
password = "password",
path = "/path",
params = "params",
query = "query",
path = "/path;params",
fragment = "fragment"
}
@ -588,8 +564,7 @@ check_build_url {
userinfo = "not used",
authority = "not used",
password = "password",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -601,8 +576,7 @@ check_build_url {
port = "port",
userinfo = "user:password",
authority = "not used",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}
@ -611,8 +585,7 @@ check_build_url {
url = "scheme://user:password@host:port/path;params?query#fragment",
scheme = "scheme",
authority = "user:password@host:port",
path = "/path",
params = "params",
path = "/path;params",
query = "query",
fragment = "fragment"
}