diff options
| author | Diego Nehab <diego.nehab@gmail.com> | 2019-02-24 17:41:10 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-02-24 17:41:10 -0300 |
| commit | e136dd3df38b10584afed55450aa111de3fd01c0 (patch) | |
| tree | 8b94521c7016f51e30c476ad521c9cf7e6189ff5 /src | |
| parent | 144fa01c2f204e3b1b13c834f2644d100dba701b (diff) | |
| parent | 09ff9b650c3567c91eed62f4dd571729df2dedd4 (diff) | |
| download | luasocket-e136dd3df38b10584afed55450aa111de3fd01c0.tar.gz luasocket-e136dd3df38b10584afed55450aa111de3fd01c0.tar.bz2 luasocket-e136dd3df38b10584afed55450aa111de3fd01c0.zip | |
Merge pull request #267 from ewestbrook/prc-maxredirects
Allow overriding of hard-coded redirect limit
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 | } |
