Request stream (#1463)

* split request/response

* stream api

* fix: global variable (#1464)

* fix global variable

* fix global variable

* Add httpc.head

Co-authored-by: JTrancender <jie-email@jie-trancender.org>
This commit is contained in:
云风
2021-08-30 10:00:57 +08:00
committed by GitHub
parent 6ee8d23ac4
commit 54e733a76f
4 changed files with 254 additions and 40 deletions

View File

@@ -45,6 +45,7 @@ local function write_handshake(self, host, url, header)
if code ~= 101 then
error(string.format("websocket handshake error: code[%s] info:%s", code, body))
end
assert(body == "") -- todo: M.read may need handle it
if not recvheader["upgrade"] or recvheader["upgrade"]:lower() ~= "websocket" then
error("websocket handshake upgrade must websocket")
@@ -306,7 +307,6 @@ local function _new_client_ws(socket_id, protocol, hostname)
local obj
if protocol == "ws" then
obj = {
websocket = true,
close = function ()
socket.close(socket_id)
end,
@@ -323,7 +323,6 @@ local function _new_client_ws(socket_id, protocol, hostname)
local init = tls.init_requestfunc(socket_id, tls_ctx)
init()
obj = {
websocket = true,
close = function ()
socket.close(socket_id)
tls.closefunc(tls_ctx)()