From d7a76c7c7272b1280bd37916c2d044e36d246991 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Thu, 7 Jan 2016 16:01:17 +0800 Subject: [PATCH] If no content-length, read all. see issue #431 --- lualib/http/httpc.lua | 3 ++- lualib/http/sockethelper.lua | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lualib/http/httpc.lua b/lualib/http/httpc.lua index 09ac9288..68d3ce9c 100644 --- a/lualib/http/httpc.lua +++ b/lualib/http/httpc.lua @@ -72,7 +72,8 @@ local function request(fd, method, host, url, recvheader, header, content) body = body .. padding end else - body = nil + -- no content-length, read all + body = body .. socket.readall(fd) end end diff --git a/lualib/http/sockethelper.lua b/lualib/http/sockethelper.lua index febe4cea..cac3130d 100644 --- a/lualib/http/sockethelper.lua +++ b/lualib/http/sockethelper.lua @@ -19,6 +19,8 @@ function sockethelper.readfunc(fd) end end +sockethelper.readall = socket.readall + function sockethelper.writefunc(fd) return function(content) local ok = writebytes(fd, content)