diff options
author | xyida <522918670@qq.com> | 2018-04-26 16:39:29 +0800 |
---|---|---|
committer | xyida <522918670@qq.com> | 2018-04-26 16:39:33 +0800 |
commit | 4a3504612cda28f25ab777db94bfeab55e081e16 (patch) | |
tree | 56576633f664f922e9253960aba6addfd4d1e8c3 | |
parent | 652959890943c34d7180cae372339b91e62f0d7b (diff) | |
download | luasocket-4a3504612cda28f25ab777db94bfeab55e081e16.tar.gz luasocket-4a3504612cda28f25ab777db94bfeab55e081e16.tar.bz2 luasocket-4a3504612cda28f25ab777db94bfeab55e081e16.zip |
Fixed an issue that was mistaken for HTTP 0.9 when timeout
-rw-r--r-- | src/http.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/http.lua b/src/http.lua index a386165..79a931c 100644 --- a/src/http.lua +++ b/src/http.lua | |||
@@ -147,10 +147,15 @@ function metat.__index:sendbody(headers, source, step) | |||
147 | end | 147 | end |
148 | 148 | ||
149 | function metat.__index:receivestatusline() | 149 | function metat.__index:receivestatusline() |
150 | local status = self.try(self.c:receive(5)) | 150 | local status,ec = self.try(self.c:receive(5)) |
151 | -- identify HTTP/0.9 responses, which do not contain a status line | 151 | -- identify HTTP/0.9 responses, which do not contain a status line |
152 | -- this is just a heuristic, but is what the RFC recommends | 152 | -- this is just a heuristic, but is what the RFC recommends |
153 | if status ~= "HTTP/" then return nil, status end | 153 | if status ~= "HTTP/" then |
154 | if ec == "timeout" then | ||
155 | return 408 | ||
156 | end | ||
157 | return nil, status | ||
158 | end | ||
154 | -- otherwise proceed reading a status line | 159 | -- otherwise proceed reading a status line |
155 | status = self.try(self.c:receive("*l", status)) | 160 | status = self.try(self.c:receive("*l", status)) |
156 | local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)")) | 161 | local code = socket.skip(2, string.find(status, "HTTP/%d*%.%d* (%d%d%d)")) |
@@ -325,6 +330,8 @@ end | |||
325 | if not code then | 330 | if not code then |
326 | h:receive09body(status, nreqt.sink, nreqt.step) | 331 | h:receive09body(status, nreqt.sink, nreqt.step) |
327 | return 1, 200 | 332 | return 1, 200 |
333 | elseif code == 408 then | ||
334 | return 1, code | ||
328 | end | 335 | end |
329 | local headers | 336 | local headers |
330 | -- ignore any 100-continue messages | 337 | -- ignore any 100-continue messages |