fix websocket bugs (#1359)

* fix websocket bugs

* revert write_frame

Co-authored-by: 郑非凡 <efve.zff@alibaba-inc.com>
This commit is contained in:
EfveZombie
2021-03-10 12:35:56 +08:00
committed by GitHub
parent 6f2866e5c4
commit b0dda0483d

View File

@@ -261,6 +261,7 @@ local function resolve_accept(self, options)
try_handle(self, "handshake", header, url) try_handle(self, "handshake", header, url)
local recv_count = 0 local recv_count = 0
local recv_buf = {} local recv_buf = {}
local first_op
while true do while true do
if _isws_closed(self.id) then if _isws_closed(self.id) then
try_handle(self, "close") try_handle(self, "close")
@@ -286,11 +287,13 @@ local function resolve_accept(self, options)
if recv_count > MAX_FRAME_SIZE then if recv_count > MAX_FRAME_SIZE then
error("payload_len is too large") error("payload_len is too large")
end end
first_op = first_op or op
if fin then if fin then
local s = table.concat(recv_buf) local s = table.concat(recv_buf)
try_handle(self, "message", s, op) try_handle(self, "message", s, first_op)
recv_buf = {} -- clear recv_buf recv_buf = {} -- clear recv_buf
recv_count = 0 recv_count = 0
first_op = nil
end end
end end
end end
@@ -470,7 +473,6 @@ function M.read(id)
end end
end end
end end
assert(false)
end end