From 844165ff89c0ec7bb50ac65ce010200dba1c8d89 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 18:11:43 +0300 Subject: [PATCH 01/48] ci: Drop obsolete Travis configs --- .travis.yml | 54 ----------------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fce8a96..0000000 --- a/.travis.yml +++ /dev/null @@ -1,54 +0,0 @@ -language: erlang - -env: - global: - - LUAROCKS_BASE=luarocks-2.0.13 - matrix: - - LUA=lua5.1 LUA_DEV=liblua5.1-dev LUA_VER=5.1 LUA_SFX=5.1 LUA_INCDIR=/usr/include/lua5.1 - - LUA=lua5.2 LUA_DEV=liblua5.2-dev LUA_VER=5.2 LUA_SFX=5.2 LUA_INCDIR=/usr/include/lua5.2 - - LUA=luajit LUA_DEV=libluajit-5.1-dev LUA_VER=5.1 LUA_SFX=jit LUA_INCDIR=/usr/include/luajit-2.0 - -branches: - only: - - master - -before_install: - - if [ $LUA = "luajit" ]; then - sudo add-apt-repository ppa:mwild1/ppa -y && sudo apt-get update -y; - fi - - sudo apt-get install $LUA - - sudo apt-get install $LUA_DEV - - lua$LUA_SFX -v - # Install a recent luarocks release - - wget http://luarocks.org/releases/$LUAROCKS_BASE.tar.gz - - tar zxvpf $LUAROCKS_BASE.tar.gz - - cd $LUAROCKS_BASE - - ./configure - --lua-version=$LUA_VER --lua-suffix=$LUA_SFX --with-lua-include="$LUA_INCDIR" - - sudo make - - sudo make install - - cd $TRAVIS_BUILD_DIR - - -install: - - export DEBUG=DEBUG - - sudo -E luarocks make luasocket-scm-0.rockspec - -script: - - cd test - - lua$LUA_SFX hello.lua - - lua$LUA_SFX testsrvr.lua > /dev/null & - - lua$LUA_SFX testclnt.lua - - lua$LUA_SFX stufftest.lua - - lua$LUA_SFX excepttest.lua - - lua$LUA_SFX test_bind.lua - - lua$LUA_SFX test_getaddrinfo.lua - - lua$LUA_SFX ltn12test.lua - - lua$LUA_SFX mimetest.lua - - lua$LUA_SFX urltest.lua - - lua$LUA_SFX test_socket_error.lua - -notifications: - email: - on_success: change - on_failure: always From 2cc6f8a55c45ec9b5ad165c150259060d4d70a82 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 20:55:11 +0300 Subject: [PATCH 02/48] ci: Add workflow to confirm build completes --- .github/workflows/build.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..8265bb1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,24 @@ +name: Check build + +on: [ push, pull_request ] + +jobs: + build: + name: Check build + strategy: + fail-fast: false + matrix: + luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty"] + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup ‘lua’ + uses: leafo/gh-actions-lua@v9 + with: + luaVersion: ${{ matrix.luaVersion }} + - name: Setup ‘luarocks’ + uses: leafo/gh-actions-luarocks@v4 + - name: Make with Luarocks + run: | + luarocks make --pack-binary-rock -- luasocket-scm-3.rockspec From 2a76cb906cb955a83ed76b8e47cc76c77ce8e15f Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Fri, 16 Oct 2020 12:18:46 -0230 Subject: [PATCH 03/48] 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 fdd741da5cd0515e69572e564f2d57f336d2466b Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 20:58:52 +0300 Subject: [PATCH 04/48] Ci: Run regression tests after successful build --- .github/workflows/build.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8265bb1..64393cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,10 @@ -name: Check build +name: Test build on: [ push, pull_request ] jobs: build: - name: Check build + name: Test build on Linux strategy: fail-fast: false matrix: @@ -19,6 +19,23 @@ jobs: luaVersion: ${{ matrix.luaVersion }} - name: Setup ‘luarocks’ uses: leafo/gh-actions-luarocks@v4 - - name: Make with Luarocks + - name: Make and install locally run: | - luarocks make --pack-binary-rock -- luasocket-scm-3.rockspec + export DEBUG=DEBUG + luarocks --local make -- luasocket-scm-3.rockspec + - name: Run regression tests + run: | + eval $(luarocks --local path) + cd test + lua hello.lua + lua testsrvr.lua > /dev/null & + lua testclnt.lua + lua stufftest.lua + lua excepttest.lua + lua test_bind.lua + lua test_getaddrinfo.lua + lua ltn12test.lua + lua mimetest.lua + lua urltest.lua + lua test_socket_error.lua + kill %1 From 9787c17e589dc1b12c1f96e6bb391a7ff3dd5065 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 21:18:54 +0300 Subject: [PATCH 05/48] ci: Expand test matrix to cover Windows and macOS --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 64393cc..518de63 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,8 @@ jobs: fail-fast: false matrix: luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty"] - runs-on: ubuntu-20.04 + platform: [ "ubuntu-20.04", "windows-2022", "macos-11" ] + runs-on: ${{ matrix.platform }} steps: - name: Checkout uses: actions/checkout@v3 From 52c72694c2989c38fc9df915dcb34995d1e37404 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 21:23:58 +0300 Subject: [PATCH 06/48] ci: Disable unsupported Windows and avoid duplicate runs --- .github/workflows/build.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 518de63..d22e67f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,10 @@ name: Test build -on: [ push, pull_request ] +on: + push: + branches: + - master + pull_request: jobs: build: @@ -9,7 +13,7 @@ jobs: fail-fast: false matrix: luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty"] - platform: [ "ubuntu-20.04", "windows-2022", "macos-11" ] + platform: [ "ubuntu-20.04", "macos-11" ] # "windows-2022" not supported by gh-actions-lua runs-on: ${{ matrix.platform }} steps: - name: Checkout From f9e1d03f3c6c9fc59dd3b91716debc23aebf947f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Mar 2022 22:42:25 +0300 Subject: [PATCH 07/48] ci: Don't bother doing user-local install in ephemeral runner --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d22e67f..17cad49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,13 +24,12 @@ jobs: luaVersion: ${{ matrix.luaVersion }} - name: Setup ‘luarocks’ uses: leafo/gh-actions-luarocks@v4 - - name: Make and install locally + - name: Make and install run: | export DEBUG=DEBUG - luarocks --local make -- luasocket-scm-3.rockspec + luarocks make -- luasocket-scm-3.rockspec - name: Run regression tests run: | - eval $(luarocks --local path) cd test lua hello.lua lua testsrvr.lua > /dev/null & From f97dc8489d58aef2d038288f9a8bc69f907e17bb Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Tue, 22 Mar 2022 19:21:58 +0100 Subject: [PATCH 08/48] 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.

-