diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-02-27 18:30:32 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-02-27 18:30:32 +0000 |
commit | 7350bad6f434a8546ed669591e1bbf6ed44a5842 (patch) | |
tree | 3a11d5c51c7a809c143f58e32049d0ed672f0d54 /src/http.lua | |
parent | 8d4e240f6ae50d9b22ddc44f5e207018935da907 (diff) | |
download | luasocket-7350bad6f434a8546ed669591e1bbf6ed44a5842.tar.gz luasocket-7350bad6f434a8546ed669591e1bbf6ed44a5842.tar.bz2 luasocket-7350bad6f434a8546ed669591e1bbf6ed44a5842.zip |
Just to check out in the office.
Diffstat (limited to 'src/http.lua')
-rw-r--r-- | src/http.lua | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/http.lua b/src/http.lua index 5fb59ce..1dff11a 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -173,8 +173,10 @@ local function adjustrequest(reqt) | |||
173 | return nreqt | 173 | return nreqt |
174 | end | 174 | end |
175 | 175 | ||
176 | local function shouldredirect(reqt, code) | 176 | local function shouldredirect(reqt, code, headers) |
177 | return (reqt.redirect ~= false) and | 177 | return headers.location and |
178 | string.gsub(headers.location, "%s", "") ~= "" and | ||
179 | (reqt.redirect ~= false) and | ||
178 | (code == 301 or code == 302) and | 180 | (code == 301 or code == 302) and |
179 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") | 181 | (not reqt.method or reqt.method == "GET" or reqt.method == "HEAD") |
180 | and (not reqt.nredirects or reqt.nredirects < 5) | 182 | and (not reqt.nredirects or reqt.nredirects < 5) |
@@ -226,7 +228,7 @@ function trequest(reqt) | |||
226 | local code, headers, status | 228 | local code, headers, status |
227 | code, status = h:receivestatusline() | 229 | code, status = h:receivestatusline() |
228 | headers = h:receiveheaders() | 230 | headers = h:receiveheaders() |
229 | if shouldredirect(reqt, code) then | 231 | if shouldredirect(reqt, code, headers) then |
230 | h:close() | 232 | h:close() |
231 | return tredirect(reqt, headers) | 233 | return tredirect(reqt, headers) |
232 | elseif shouldauthorize(reqt, code) then | 234 | elseif shouldauthorize(reqt, code) then |