From 46ecb7e2dc3dd92931c6d9d99fdc9260e83077ff Mon Sep 17 00:00:00 2001 From: david <57832272+jyoui@users.noreply.github.com> Date: Tue, 1 Feb 2022 15:40:35 +0900 Subject: [PATCH 01/10] src/ltn12.lua: remove duplicated codes --- src/ltn12.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ltn12.lua b/src/ltn12.lua index f1e05e1..4cb17f5 100644 --- a/src/ltn12.lua +++ b/src/ltn12.lua @@ -11,6 +11,8 @@ local string = require("string") local table = require("table") local unpack = unpack or table.unpack local base = _G +local select = select + local _M = {} if module then -- heuristic for exporting a global package table ltn12 = _M -- luacheck: ignore @@ -22,8 +24,6 @@ _M.source = source _M.sink = sink _M.pump = pump -local unpack = unpack or table.unpack - -- 2048 seems to be better in windows... _M.BLOCKSIZE = 2048 _M._VERSION = "LTN12 1.0.3" @@ -45,7 +45,7 @@ end -- (thanks to Wim Couwenberg) function filter.chain(...) local arg = {...} - local n = base.select('#',...) + local n = select('#',...) local top, index = 1, 1 local retry = "" return function(chunk) From e3c17b002ae4747c033c374d39538d4e242dbb22 Mon Sep 17 00:00:00 2001 From: "E. Westbrook" Date: Mon, 11 Mar 2019 02:07:45 -0600 Subject: [PATCH 02/10] Add src\compat.c to mime.vcxproj and socket.vcxproj --- mime.vcxproj | 1 + socket.vcxproj | 1 + 2 files changed, 2 insertions(+) diff --git a/mime.vcxproj b/mime.vcxproj index 43acee9..575f985 100755 --- a/mime.vcxproj +++ b/mime.vcxproj @@ -20,6 +20,7 @@ + {128E8BD0-174A-48F0-8771-92B1E8D18713} diff --git a/socket.vcxproj b/socket.vcxproj index 305c094..51ebc68 100755 --- a/socket.vcxproj +++ b/socket.vcxproj @@ -21,6 +21,7 @@ + From 2a76cb906cb955a83ed76b8e47cc76c77ce8e15f Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Fri, 16 Oct 2020 12:18:46 -0230 Subject: [PATCH 03/10] http.lua: set transfer-encoding if source and no content-length If a source is specified without a content-length header, LuaSocket sends the data in the chunked transfer coding; however, it doesn't set the transfer-encoding header. While I recognize that the user can set this manually, this is a gotcha that has caught me multiple times. RFC7230, section 3.3.3 (https://tools.ietf.org/html/rfc7230#section-3.3.3) is clear about this; if neither content-length nor transfer-encoding chunked are specified, the request message body length is zero. While some servers may ignore this, I have encountered several that follow the RFC in this regard, most recently golang's net/http. --- src/http.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/http.lua b/src/http.lua index e3a1742..1330355 100644 --- a/src/http.lua +++ b/src/http.lua @@ -283,6 +283,13 @@ local function adjustrequest(reqt) nreqt.uri = reqt.uri or adjusturi(nreqt) -- adjust headers in request nreqt.headers = adjustheaders(nreqt) + if nreqt.source + and not nreqt.headers["content-length"] + and not nreqt.headers["transfer-encoding"] + then + nreqt.headers["transfer-encoding"] = "chunked" + end + -- ajust host and port if there is a proxy nreqt.host, nreqt.port = adjustproxy(nreqt) return nreqt From f97dc8489d58aef2d038288f9a8bc69f907e17bb Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 22 Mar 2022 19:21:58 +0100 Subject: [PATCH 04/10] fix(docs) fix html linter issues in the docs (#358) --- doc/dns.html | 78 +++++------ doc/ftp.html | 122 ++++++++--------- doc/http.html | 142 ++++++++++---------- doc/index.html | 140 +++++++++---------- doc/ltn12.html | 200 ++++++++++++++-------------- doc/mime.html | 302 ++++++++++++++++++++--------------------- doc/reference.html | 22 +-- doc/smtp.html | 191 +++++++++++++------------- doc/socket.html | 256 +++++++++++++++++------------------ doc/tcp.html | 325 +++++++++++++++++++++++---------------------- doc/udp.html | 94 ++++++------- 11 files changed, 938 insertions(+), 934 deletions(-) diff --git a/doc/dns.html b/doc/dns.html index c4a0472..56ce3ba 100644 --- a/doc/dns.html +++ b/doc/dns.html @@ -1,4 +1,4 @@ - @@ -13,22 +13,22 @@ -
+

- -
-LuaSocket +
+LuaSocket
Network support for the Lua language +
Network support for the Lua language
-

+

home · download · installation · introduction · -reference +reference


@@ -36,14 +36,14 @@ -

DNS

+

DNS

-IPv4 name resolution functions -dns.toip +IPv4 name resolution functions +dns.toip and -dns.tohostname -return all information obtained from +dns.tohostname +return all information obtained from the resolver in a table of the form:

@@ -60,10 +60,10 @@ Note that the alias list can be empty.

-The more general name resolution function -dns.getaddrinfo, which +The more general name resolution function +dns.getaddrinfo, which supports both IPv6 and IPv4, -returns all information obtained from +returns all information obtained from the resolver in a table of the form:

@@ -88,82 +88,82 @@ addresses, and "inet6" for IPv6 addresses. -

+

socket.dns.getaddrinfo(address)

-

-Converts from host name to address. +

+Converts from host name to address.

-

-Address can be an IPv4 or IPv6 address or host name. +

+Address can be an IPv4 or IPv6 address or host name.

-

+

The function returns a table with all information returned by the resolver. In case of error, the function returns nil -followed by an error message. +followed by an error message.

-

+

socket.dns.gethostname()

-

-Returns the standard host name for the machine as a string. +

+Returns the standard host name for the machine as a string.

-

+

socket.dns.tohostname(address)

-

+

Converts from IPv4 address to host name.

-

-Address can be an IP address or host name. +

+Address can be an IP address or host name.

-

+

The function returns a string with the canonic host name of the given address, followed by a table with all information returned by the resolver. In case of error, the function returns nil -followed by an error message. +followed by an error message.

-

+

socket.dns.toip(address)

-

+

Converts from host name to IPv4 address.

-

-Address can be an IP address or host name. +

+Address can be an IP address or host name.

-

+

Returns a string with the first IP address found for address, followed by a table with all information returned by the resolver. In case of error, the function returns nil followed by an error -message. +message.

-