aboutsummaryrefslogtreecommitdiff
path: root/src/http.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/http.lua')
-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