mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
modify from http folder (#1470)
* delete unused var and add used arg * use interface from stream
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
local internal = require "http.internal"
|
||||
|
||||
local table = table
|
||||
local string = string
|
||||
local type = type
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user