close socket after request

This commit is contained in:
Cloud Wu
2014-10-22 11:29:03 +08:00
parent 24857a3d8d
commit 9bdc36526e

View File

@@ -81,10 +81,10 @@ function httpc.request(method, host, url, recvheader, header, content)
end
local fd = socket.connect(hostname, port)
local ok , statuscode, body = pcall(request, fd,method, host, url, recvheader, header, content)
socket.close(fd)
if ok then
return statuscode, body
else
socket.close(fd)
error(statuscode)
end
end