aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego.nehab@gmail.com>2019-02-24 18:01:33 -0300
committerGitHub <noreply@github.com>2019-02-24 18:01:33 -0300
commitfa807f3ffdf442df66b8807f374aba8cb3bd38da (patch)
treef55fd80a8ccd159930b81a911524a00398019570
parenta9c75cb099e8db00d17a2314df2dca138e444314 (diff)
parent4a3504612cda28f25ab777db94bfeab55e081e16 (diff)
downloadluasocket-fa807f3ffdf442df66b8807f374aba8cb3bd38da.tar.gz
luasocket-fa807f3ffdf442df66b8807f374aba8cb3bd38da.tar.bz2
luasocket-fa807f3ffdf442df66b8807f374aba8cb3bd38da.zip
Merge pull request #246 from xyida/yoda
Fixed an issue that was mistaken for HTTP 0.9 when timeout
-rw-r--r--src/http.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http.lua b/src/http.lua
index fb729b2..19b4dd3 100644
--- a/src/http.lua
+++ b/src/http.lua
@@ -151,10 +151,15 @@ function metat.__index:sendbody(headers, source, step)
151end 151end
152 152
153function metat.__index:receivestatusline() 153function metat.__index:receivestatusline()
154 local status = self.try(self.c:receive(5)) 154 local status,ec = self.try(self.c:receive(5))
155 -- identify HTTP/0.9 responses, which do not contain a status line 155 -- identify HTTP/0.9 responses, which do not contain a status line
156 -- this is just a heuristic, but is what the RFC recommends 156 -- this is just a heuristic, but is what the RFC recommends
157 if status ~= "HTTP/" then return nil, status end 157 if status ~= "HTTP/" then
158 if ec == "timeout" then
159 return 408
160 end
161 return nil, status
162 end
158 -- otherwise proceed reading a status line 163 -- otherwise proceed reading a status line
159 status = self.try(self.c:receive("*l", status)) 164 status = self.try(self.c:receive("*l", status))
160 local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)")) 165 local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
@@ -336,6 +341,8 @@ end
336 if not code then 341 if not code then
337 h:receive09body(status, nreqt.sink, nreqt.step) 342 h:receive09body(status, nreqt.sink, nreqt.step)
338 return 1, 200 343 return 1, 200
344 elseif code == 408 then
345 return 1, code
339 end 346 end
340 local headers 347 local headers
341 -- ignore any 100-continue messages 348 -- ignore any 100-continue messages