mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
Merge pull request #246 from xyida/yoda
Fixed an issue that was mistaken for HTTP 0.9 when timeout
This commit is contained in:
commit
fa807f3ffd
11
src/http.lua
11
src/http.lua
@ -151,10 +151,15 @@ function metat.__index:sendbody(headers, source, step)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function metat.__index:receivestatusline()
|
function metat.__index:receivestatusline()
|
||||||
local status = self.try(self.c:receive(5))
|
local status,ec = self.try(self.c:receive(5))
|
||||||
-- identify HTTP/0.9 responses, which do not contain a status line
|
-- identify HTTP/0.9 responses, which do not contain a status line
|
||||||
-- this is just a heuristic, but is what the RFC recommends
|
-- this is just a heuristic, but is what the RFC recommends
|
||||||
if status ~= "HTTP/" then return nil, status end
|
if status ~= "HTTP/" then
|
||||||
|
if ec == "timeout" then
|
||||||
|
return 408
|
||||||
|
end
|
||||||
|
return nil, status
|
||||||
|
end
|
||||||
-- otherwise proceed reading a status line
|
-- otherwise proceed reading a status line
|
||||||
status = self.try(self.c:receive("*l", status))
|
status = self.try(self.c:receive("*l", status))
|
||||||
local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
|
local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)"))
|
||||||
@ -336,6 +341,8 @@ end
|
|||||||
if not code then
|
if not code then
|
||||||
h:receive09body(status, nreqt.sink, nreqt.step)
|
h:receive09body(status, nreqt.sink, nreqt.step)
|
||||||
return 1, 200
|
return 1, 200
|
||||||
|
elseif code == 408 then
|
||||||
|
return 1, code
|
||||||
end
|
end
|
||||||
local headers
|
local headers
|
||||||
-- ignore any 100-continue messages
|
-- ignore any 100-continue messages
|
||||||
|
Loading…
Reference in New Issue
Block a user