mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 07:29:23 +00:00
Always close WS, handle close message
This commit is contained in:
parent
14b33f0747
commit
7b760da8b3
1 changed files with 9 additions and 8 deletions
|
@ -5150,6 +5150,9 @@ static int LuaReadWS(lua_State *L) {
|
|||
luaL_error(L, "Could not read WS data");
|
||||
}
|
||||
|
||||
if ((wshdr[0] & 0xF) == 0x8)
|
||||
luaL_error(L, "WS connection closed");
|
||||
|
||||
for (i = 0, amt = amtread; i < got; ++i, ++amt) inbuf.p[amt] ^= mask[i & 0x3];
|
||||
|
||||
lua_pushlstring(L, inbuf.p + amtread, got);
|
||||
|
@ -6479,14 +6482,12 @@ static bool StreamWS(char *p) {
|
|||
if (Send(iov, 4) == -1) break;
|
||||
}
|
||||
|
||||
if (rc != -1) {
|
||||
wshdr[0] = 0x8;
|
||||
wshdr[1] = 0;
|
||||
iov[0].iov_len = 2;
|
||||
Send(iov, 1);
|
||||
} else {
|
||||
connectionclose = true;
|
||||
}
|
||||
wshdr[0] = 0x8 | (1 << 7);
|
||||
wshdr[1] = 0;
|
||||
iov[0].iov_len = 2;
|
||||
Send(iov, 1);
|
||||
connectionclose = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue