diff options
-rw-r--r-- | doc/http.html | 8 | ||||
-rw-r--r-- | luasocket-scm-0.rockspec | 2 | ||||
-rw-r--r-- | src/compat.h | 2 | ||||
-rw-r--r-- | src/http.lua | 5 | ||||
-rw-r--r-- | src/makefile | 24 |
5 files changed, 24 insertions, 17 deletions
diff --git a/doc/http.html b/doc/http.html index 3b7a8b1..78f785a 100644 --- a/doc/http.html +++ b/doc/http.html | |||
@@ -135,7 +135,8 @@ http.<b>request{</b><br> | |||
135 | [step = <i>LTN12 pump step</i>,]<br> | 135 | [step = <i>LTN12 pump step</i>,]<br> |
136 | [proxy = <i>string</i>,]<br> | 136 | [proxy = <i>string</i>,]<br> |
137 | [redirect = <i>boolean</i>,]<br> | 137 | [redirect = <i>boolean</i>,]<br> |
138 | [create = <i>function</i>]<br> | 138 | [create = <i>function</i>,]<br> |
139 | [maxredirects = <i>number</i>]<br> | ||
139 | <b>}</b> | 140 | <b>}</b> |
140 | </p> | 141 | </p> |
141 | 142 | ||
@@ -185,6 +186,7 @@ Defaults to the LTN12 <tt>pump.step</tt> function. | |||
185 | function from automatically following 301 or 302 server redirect messages; | 186 | function from automatically following 301 or 302 server redirect messages; |
186 | <li><tt>create</tt>: An optional function to be used instead of | 187 | <li><tt>create</tt>: An optional function to be used instead of |
187 | <a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. | 188 | <a href=tcp.html#socket.tcp><tt>socket.tcp</tt></a> when the communications socket is created. |
189 | <li><tt>maxredirects</tt>: An optional number specifying the maximum number of redirects to follow. Defaults to <tt>5</tt> if not specified. A boolean <tt>false</tt> value means no maximum (unlimited). | ||
188 | </ul> | 190 | </ul> |
189 | 191 | ||
190 | <p class=return> | 192 | <p class=return> |
@@ -324,8 +326,8 @@ r, c = http.request { | |||
324 | </p> | 326 | </p> |
325 | <p> | 327 | <p> |
326 | <small> | 328 | <small> |
327 | Last modified by Diego Nehab on <br> | 329 | Last modified by Eric Westbrook on <br> |
328 | Thu Apr 20 00:25:26 EDT 2006 | 330 | Sat Feb 23 19:09:42 UTC 2019 |
329 | </small> | 331 | </small> |
330 | </p> | 332 | </p> |
331 | </center> | 333 | </center> |
diff --git a/luasocket-scm-0.rockspec b/luasocket-scm-0.rockspec index 61bd645..c827e46 100644 --- a/luasocket-scm-0.rockspec +++ b/luasocket-scm-0.rockspec | |||
@@ -75,7 +75,7 @@ local function make_plat(plat) | |||
75 | modules["socket.core"].libraries = {"network"} | 75 | modules["socket.core"].libraries = {"network"} |
76 | end | 76 | end |
77 | modules["socket.unix"] = { | 77 | modules["socket.unix"] = { |
78 | sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/unix.c" }, | 78 | sources = { "src/buffer.c", "src/auxiliar.c", "src/options.c", "src/timeout.c", "src/io.c", "src/usocket.c", "src/unix.c", "src/unixdgram.c", "src/unixstream.c" }, |
79 | defines = defines[plat], | 79 | defines = defines[plat], |
80 | incdir = "/src" | 80 | incdir = "/src" |
81 | } | 81 | } |
diff --git a/src/compat.h b/src/compat.h index e2ab307..49e83f9 100644 --- a/src/compat.h +++ b/src/compat.h | |||
@@ -5,6 +5,8 @@ | |||
5 | #include "lauxlib.h" | 5 | #include "lauxlib.h" |
6 | 6 | ||
7 | #if LUA_VERSION_NUM==501 | 7 | #if LUA_VERSION_NUM==501 |
8 | #define luaL_setfuncs socket_setfuncs | ||
9 | #define luaL_testudata socket_testudata | ||
8 | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); | 10 | void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup); |
9 | void *luaL_testudata ( lua_State *L, int arg, const char *tname); | 11 | void *luaL_testudata ( lua_State *L, int arg, const char *tname); |
10 | #endif | 12 | #endif |
diff --git a/src/http.lua b/src/http.lua index 6b26a0a..fb729b2 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -285,7 +285,9 @@ local function shouldredirect(reqt, code, headers) | |||
285 | return (reqt.redirect ~= false) and | 285 | return (reqt.redirect ~= false) and |
286 | (code == 301 or code == 302 or code == 303 or code == 307) and | 286 | (code == 301 or code == 302 or code == 303 or code == 307) and |
287 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") | 287 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") |
288 | and (not reqt.nredirects or reqt.nredirects < 5) | 288 | and ((false == reqt.maxredirects) |
289 | or ((reqt.nredirects or 0) | ||
290 | < (reqt.maxredirects or 5))) | ||
289 | end | 291 | end |
290 | 292 | ||
291 | local function shouldreceivebody(reqt, code) | 293 | local function shouldreceivebody(reqt, code) |
@@ -307,6 +309,7 @@ local trequest, tredirect | |||
307 | sink = reqt.sink, | 309 | sink = reqt.sink, |
308 | headers = reqt.headers, | 310 | headers = reqt.headers, |
309 | proxy = reqt.proxy, | 311 | proxy = reqt.proxy, |
312 | maxredirects = reqt.maxredirects, | ||
310 | nredirects = (reqt.nredirects or 0) + 1, | 313 | nredirects = (reqt.nredirects or 0) + 1, |
311 | create = reqt.create | 314 | create = reqt.create |
312 | } | 315 | } |
diff --git a/src/makefile b/src/makefile index 0f4b359..cc1ec7e 100644 --- a/src/makefile +++ b/src/makefile | |||
@@ -35,7 +35,7 @@ DEBUG?=NODEBUG | |||
35 | # LUAINC_macosx: | 35 | # LUAINC_macosx: |
36 | # /opt/local/include | 36 | # /opt/local/include |
37 | LUAINC_macosx_base?=/opt/local/include | 37 | LUAINC_macosx_base?=/opt/local/include |
38 | LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV) | 38 | LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUAV) $(LUAINC_macosx_base)/lua$(LUAV) |
39 | # FIXME default should this default to fink or to macports? | 39 | # FIXME default should this default to fink or to macports? |
40 | # What happens when more than one Lua version is installed? | 40 | # What happens when more than one Lua version is installed? |
41 | LUAPREFIX_macosx?=/opt/local | 41 | LUAPREFIX_macosx?=/opt/local |
@@ -48,7 +48,7 @@ LDIR_macosx?=share/lua/$(LUAV) | |||
48 | # /usr/local/include/lua$(LUAV) | 48 | # /usr/local/include/lua$(LUAV) |
49 | # where lua headers are found for linux builds | 49 | # where lua headers are found for linux builds |
50 | LUAINC_linux_base?=/usr/include | 50 | LUAINC_linux_base?=/usr/include |
51 | LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV) | 51 | LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUAV) $(LUAINC_linux_base)/lua$(LUAV) |
52 | LUAPREFIX_linux?=/usr/local | 52 | LUAPREFIX_linux?=/usr/local |
53 | CDIR_linux?=lib/lua/$(LUAV) | 53 | CDIR_linux?=lib/lua/$(LUAV) |
54 | LDIR_linux?=share/lua/$(LUAV) | 54 | LDIR_linux?=share/lua/$(LUAV) |
@@ -57,7 +57,7 @@ LDIR_linux?=share/lua/$(LUAV) | |||
57 | # /usr/local/include/lua$(LUAV) | 57 | # /usr/local/include/lua$(LUAV) |
58 | # where lua headers are found for freebsd builds | 58 | # where lua headers are found for freebsd builds |
59 | LUAINC_freebsd_base?=/usr/local/include/ | 59 | LUAINC_freebsd_base?=/usr/local/include/ |
60 | LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUAV) | 60 | LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua/$(LUAV) $(LUAINC_freebsd_base)/lua$(LUAV) |
61 | LUAPREFIX_freebsd?=/usr/local/ | 61 | LUAPREFIX_freebsd?=/usr/local/ |
62 | CDIR_freebsd?=lib/lua/$(LUAV) | 62 | CDIR_freebsd?=lib/lua/$(LUAV) |
63 | LDIR_freebsd?=share/lua/$(LUAV) | 63 | LDIR_freebsd?=share/lua/$(LUAV) |
@@ -66,7 +66,7 @@ LDIR_freebsd?=share/lua/$(LUAV) | |||
66 | # LUAINC_mingw: | 66 | # LUAINC_mingw: |
67 | # /opt/local/include | 67 | # /opt/local/include |
68 | LUAINC_mingw_base?=/usr/include | 68 | LUAINC_mingw_base?=/usr/include |
69 | LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV) | 69 | LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUAV) $(LUAINC_mingw_base)/lua$(LUAV) |
70 | LUALIB_mingw_base?=/usr/bin | 70 | LUALIB_mingw_base?=/usr/bin |
71 | LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll | 71 | LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUAV)/lua$(subst .,,$(LUAV)).dll |
72 | LUAPREFIX_mingw?=/usr | 72 | LUAPREFIX_mingw?=/usr |
@@ -78,7 +78,7 @@ LDIR_mingw?=lua/$(LUAV)/lua | |||
78 | # LUALIB_win32: | 78 | # LUALIB_win32: |
79 | # where lua headers and libraries are found for win32 builds | 79 | # where lua headers and libraries are found for win32 builds |
80 | LUAPREFIX_win32?= | 80 | LUAPREFIX_win32?= |
81 | LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV) | 81 | LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUAV) $(LUAPREFIX_win32)/include/lua$(LUAV) |
82 | PLATFORM_win32?=Release | 82 | PLATFORM_win32?=Release |
83 | CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32) | 83 | CDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32) |
84 | LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua | 84 | LDIR_win32?=bin/lua/$(LUAV)/$(PLATFORM_win32)/lua |
@@ -88,7 +88,7 @@ LUALIBNAME_win32?=lua$(subst .,,$(LUAV)).lib | |||
88 | 88 | ||
89 | # LUAINC_solaris: | 89 | # LUAINC_solaris: |
90 | LUAINC_solaris_base?=/usr/include | 90 | LUAINC_solaris_base?=/usr/include |
91 | LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV) | 91 | LUAINC_solaris?=$(LUAINC_solaris_base)/lua/$(LUAV) $(LUAINC_solaris_base)/lua$(LUAV) |
92 | LUAPREFIX_solaris?=/usr/local | 92 | LUAPREFIX_solaris?=/usr/local |
93 | CDIR_solaris?=lib/lua/$(LUAV) | 93 | CDIR_solaris?=lib/lua/$(LUAV) |
94 | LDIR_solaris?=share/lua/$(LUAV) | 94 | LDIR_solaris?=share/lua/$(LUAV) |
@@ -153,7 +153,7 @@ DEF_macosx= -DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN \ | |||
153 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 153 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
154 | -DUNIX_API='__attribute__((visibility("default")))' \ | 154 | -DUNIX_API='__attribute__((visibility("default")))' \ |
155 | -DMIME_API='__attribute__((visibility("default")))' | 155 | -DMIME_API='__attribute__((visibility("default")))' |
156 | CFLAGS_macosx= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \ | 156 | CFLAGS_macosx=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common \ |
157 | -fvisibility=hidden | 157 | -fvisibility=hidden |
158 | LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o | 158 | LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o |
159 | LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc | 159 | LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc |
@@ -169,7 +169,7 @@ DEF_linux=-DLUASOCKET_$(DEBUG) \ | |||
169 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 169 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
170 | -DUNIX_API='__attribute__((visibility("default")))' \ | 170 | -DUNIX_API='__attribute__((visibility("default")))' \ |
171 | -DMIME_API='__attribute__((visibility("default")))' | 171 | -DMIME_API='__attribute__((visibility("default")))' |
172 | CFLAGS_linux= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \ | 172 | CFLAGS_linux=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ |
173 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden | 173 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden |
174 | LDFLAGS_linux=-O -shared -fpic -o | 174 | LDFLAGS_linux=-O -shared -fpic -o |
175 | LD_linux=gcc | 175 | LD_linux=gcc |
@@ -185,7 +185,7 @@ DEF_freebsd=-DLUASOCKET_$(DEBUG) -DUNIX_HAS_SUN_LEN \ | |||
185 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 185 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
186 | -DUNIX_API='__attribute__((visibility("default")))' \ | 186 | -DUNIX_API='__attribute__((visibility("default")))' \ |
187 | -DMIME_API='__attribute__((visibility("default")))' | 187 | -DMIME_API='__attribute__((visibility("default")))' |
188 | CFLAGS_freebsd= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \ | 188 | CFLAGS_freebsd=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ |
189 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden | 189 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden |
190 | LDFLAGS_freebsd=-O -shared -fpic -o | 190 | LDFLAGS_freebsd=-O -shared -fpic -o |
191 | LD_freebsd=gcc | 191 | LD_freebsd=gcc |
@@ -201,7 +201,7 @@ DEF_solaris=-DLUASOCKET_$(DEBUG) \ | |||
201 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ | 201 | -DLUASOCKET_API='__attribute__((visibility("default")))' \ |
202 | -DUNIX_API='__attribute__((visibility("default")))' \ | 202 | -DUNIX_API='__attribute__((visibility("default")))' \ |
203 | -DMIME_API='__attribute__((visibility("default")))' | 203 | -DMIME_API='__attribute__((visibility("default")))' |
204 | CFLAGS_solaris=-I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \ | 204 | CFLAGS_solaris=$(LUAINC:%=-I%) $(DEF) -Wall -Wshadow -Wextra \ |
205 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden | 205 | -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden |
206 | LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o | 206 | LDFLAGS_solaris=-lnsl -lsocket -lresolv -O -shared -fpic -o |
207 | LD_solaris=gcc | 207 | LD_solaris=gcc |
@@ -216,7 +216,7 @@ CC_mingw=gcc | |||
216 | DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \ | 216 | DEF_mingw= -DLUASOCKET_INET_PTON -DLUASOCKET_$(DEBUG) \ |
217 | -DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \ | 217 | -DWINVER=0x0501 -DLUASOCKET_API='__declspec(dllexport)' \ |
218 | -DMIME_API='__declspec(dllexport)' | 218 | -DMIME_API='__declspec(dllexport)' |
219 | CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \ | 219 | CFLAGS_mingw=$(LUAINC:%=-I%) $(DEF) -Wall -O2 -fno-common \ |
220 | -fvisibility=hidden | 220 | -fvisibility=hidden |
221 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o | 221 | LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -lws2_32 -o |
222 | LD_mingw=gcc | 222 | LD_mingw=gcc |
@@ -233,7 +233,7 @@ DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \ | |||
233 | //D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \ | 233 | //D "LUASOCKET_API=__declspec(dllexport)" //D "_CRT_SECURE_NO_WARNINGS" \ |
234 | //D "_WINDLL" //D "MIME_API=__declspec(dllexport)" \ | 234 | //D "_WINDLL" //D "MIME_API=__declspec(dllexport)" \ |
235 | //D "LUASOCKET_$(DEBUG)" | 235 | //D "LUASOCKET_$(DEBUG)" |
236 | CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo | 236 | CFLAGS_win32=$(LUAINC:%=//I "%") $(DEF) //O2 //Ot //MD //W3 //nologo |
237 | LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \ | 237 | LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \ |
238 | //MANIFEST //MANIFESTFILE:"intermediate.manifest" \ | 238 | //MANIFEST //MANIFESTFILE:"intermediate.manifest" \ |
239 | //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ | 239 | //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \ |