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: src/ltn12.lua: remove duplicated codes --- src/ltn12.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') 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) -- cgit v1.2.3-55-g6feb From 2a76cb906cb955a83ed76b8e47cc76c77ce8e15f Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Fri, 16 Oct 2020 12:18:46 -0230 Subject: 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(+) (limited to 'src') 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 -- cgit v1.2.3-55-g6feb From d9c08114da2ec8950498f71939f92a6dc0d237c1 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Wed, 23 Mar 2022 17:11:43 +0100 Subject: chore; add Lua 5.4 to make files --- makefile | 6 ++++++ src/makefile | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/makefile b/makefile index f766a25..63d9985 100755 --- a/makefile +++ b/makefile @@ -33,6 +33,9 @@ install-both: $(MAKE) clean @cd src; $(MAKE) $(PLAT) LUAV=5.3 @cd src; $(MAKE) install LUAV=5.3 + $(MAKE) clean + @cd src; $(MAKE) $(PLAT) LUAV=5.4 + @cd src; $(MAKE) install LUAV=5.4 install-both-unix: $(MAKE) clean @@ -44,6 +47,9 @@ install-both-unix: $(MAKE) clean @cd src; $(MAKE) $(PLAT) LUAV=5.3 @cd src; $(MAKE) install-unix LUAV=5.3 + $(MAKE) clean + @cd src; $(MAKE) $(PLAT) LUAV=5.4 + @cd src; $(MAKE) install-unix LUAV=5.4 .PHONY: test diff --git a/src/makefile b/src/makefile index 522d378..f95498a 100755 --- a/src/makefile +++ b/src/makefile @@ -16,7 +16,7 @@ # platform to build for PLAT?=linux -# LUAV: 5.1 5.2 +# LUAV: 5.1 5.2 5.3 5.4 # lua version to build against LUAV?=5.1 @@ -163,7 +163,7 @@ O_macosx=o CC_macosx=gcc DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN CFLAGS_macosx=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common -LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o +LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o LD_macosx=gcc SOCKET_macosx=usocket.o @@ -176,7 +176,7 @@ CC_linux=gcc DEF_linux=-DLUASOCKET_$(DEBUG) CFLAGS_linux=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ -Wimplicit -O2 -ggdb3 -fpic -LDFLAGS_linux=-O -shared -fpic -o +LDFLAGS_linux=-O -shared -fpic -o LD_linux=gcc SOCKET_linux=usocket.o @@ -189,7 +189,7 @@ CC_freebsd=gcc DEF_freebsd=-DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN CFLAGS_freebsd=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ -Wimplicit -O2 -ggdb3 -fpic -LDFLAGS_freebsd=-O -shared -fpic -o +LDFLAGS_freebsd=-O -shared -fpic -o LD_freebsd=gcc SOCKET_freebsd=usocket.o @@ -202,7 +202,7 @@ CC_solaris=gcc DEF_solaris=-DLUASOCKET_$(DEBUG) CFLAGS_solaris=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ -Wimplicit -O2 -ggdb3 -fpic -LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o +LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o LD_solaris=gcc SOCKET_solaris=usocket.o @@ -215,7 +215,7 @@ CC_mingw=gcc DEF_mingw= -DLUASOCKET_$(DEBUG) \ -DWINVER=0x0501 CFLAGS_mingw=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common -LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o +LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o LD_mingw=gcc SOCKET_mingw=wsocket.o -- cgit v1.2.3-55-g6feb