modify from http folder (#1470)

* delete unused var and add used arg

* use interface from stream
This commit is contained in:
zhuilang
2021-09-01 07:12:27 +08:00
committed by GitHub
parent 54e733a76f
commit 987bb3df47
4 changed files with 7 additions and 10 deletions

View File

@@ -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

View File

@@ -1,6 +1,5 @@
local internal = require "http.internal"
local table = table
local string = string
local type = type

View File

@@ -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)

View File

@@ -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)