diff options
| author | E. Westbrook <github@westbrook.io> | 2018-07-13 12:52:26 -0600 |
|---|---|---|
| committer | E. Westbrook <github@westbrook.io> | 2019-02-23 12:23:17 -0700 |
| commit | 09ff9b650c3567c91eed62f4dd571729df2dedd4 (patch) | |
| tree | 8b94521c7016f51e30c476ad521c9cf7e6189ff5 /src | |
| parent | 144fa01c2f204e3b1b13c834f2644d100dba701b (diff) | |
| download | luasocket-09ff9b650c3567c91eed62f4dd571729df2dedd4.tar.gz luasocket-09ff9b650c3567c91eed62f4dd571729df2dedd4.tar.bz2 luasocket-09ff9b650c3567c91eed62f4dd571729df2dedd4.zip | |
http.lua: allow override of hard-coded 5 max redirects
Diffstat (limited to 'src')
| -rw-r--r-- | src/http.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/http.lua b/src/http.lua index a386165..8bda0d8 100644 --- a/src/http.lua +++ b/src/http.lua | |||
| @@ -277,7 +277,9 @@ local function shouldredirect(reqt, code, headers) | |||
| 277 | return (reqt.redirect ~= false) and | 277 | return (reqt.redirect ~= false) and |
| 278 | (code == 301 or code == 302 or code == 303 or code == 307) and | 278 | (code == 301 or code == 302 or code == 303 or code == 307) and |
| 279 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") | 279 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") |
| 280 | and (not reqt.nredirects or reqt.nredirects < 5) | 280 | and ((false == reqt.maxredirects) |
| 281 | or ((reqt.nredirects or 0) | ||
| 282 | < (reqt.maxredirects or 5))) | ||
| 281 | end | 283 | end |
| 282 | 284 | ||
| 283 | local function shouldreceivebody(reqt, code) | 285 | local function shouldreceivebody(reqt, code) |
| @@ -299,6 +301,7 @@ local trequest, tredirect | |||
| 299 | sink = reqt.sink, | 301 | sink = reqt.sink, |
| 300 | headers = reqt.headers, | 302 | headers = reqt.headers, |
| 301 | proxy = reqt.proxy, | 303 | proxy = reqt.proxy, |
| 304 | maxredirects = reqt.maxredirects, | ||
| 302 | nredirects = (reqt.nredirects or 0) + 1, | 305 | nredirects = (reqt.nredirects or 0) + 1, |
| 303 | create = reqt.create | 306 | create = reqt.create |
| 304 | } | 307 | } |
