diff --git a/lualib/http/httpc.lua b/lualib/http/httpc.lua index 7fdd721d..058e28a4 100644 --- a/lualib/http/httpc.lua +++ b/lualib/http/httpc.lua @@ -1,6 +1,5 @@ local skynet = require "skynet" local socket = require "http.sockethelper" -local url = require "http.url" local internal = require "http.internal" local dns = require "skynet.dns" local string = string @@ -131,7 +130,7 @@ function httpc.head(hostname, url, recvheader, header, content) end end -function httpc.request_stream(method, hostname, url, header, content) +function httpc.request_stream(method, hostname, url, recvheader, header, content) local fd, interface, host = connect(hostname, httpc.timeout) local ok , statuscode, body , header = pcall(internal.request, interface, method, host, url, recvheader, header, content) interface.finish = true -- don't shutdown fd in timeout diff --git a/lualib/http/httpd.lua b/lualib/http/httpd.lua index 0131db0a..1575f5a6 100644 --- a/lualib/http/httpd.lua +++ b/lualib/http/httpd.lua @@ -1,6 +1,5 @@ local internal = require "http.internal" -local table = table local string = string local type = type diff --git a/lualib/http/internal.lua b/lualib/http/internal.lua index 02aeef32..db56ab2b 100644 --- a/lualib/http/internal.lua +++ b/lualib/http/internal.lua @@ -251,7 +251,7 @@ local function stream_length(length) return function(stream) local body = stream._body if body == nil then - local ret, padding = interface.read() + local ret, padding = stream._interface.read() if not ret then -- disconnected body = padding @@ -353,7 +353,7 @@ function M.response_stream(interface, code, body, header) local read_func if mode == "chunked" then - readfunc = stream_chunked + read_func = stream_chunked else -- identity mode local length = header["content-length"] @@ -361,11 +361,11 @@ function M.response_stream(interface, code, body, header) length = tonumber(length) end if length then - readfunc = stream_length(length) + read_func = stream_length(length) elseif code == 204 or code == 304 or code < 200 then - readfunc = stream_nobody + read_func = stream_nobody else - readfunc = stream_all + read_func = stream_all end end @@ -375,7 +375,7 @@ function M.response_stream(interface, code, body, header) status = code, _body = body, _interface = interface, - _reading = readfunc, + _reading = read_func, header = header, connected = true, }, stream) diff --git a/lualib/http/tlshelper.lua b/lualib/http/tlshelper.lua index 04a15b51..05e3d3ae 100644 --- a/lualib/http/tlshelper.lua +++ b/lualib/http/tlshelper.lua @@ -77,7 +77,6 @@ function tlshelper.writefunc(fd, tls_ctx) end function tlshelper.readallfunc(fd, tls_ctx) - local readfunc = socket.readfunc(fd) return function () local ds = socket.readall(fd) local s = tls_ctx:read(ds)