mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-17 15:02:24 +00:00
LibWebSocket: Send closing frame when server begins a closing handshake
This commit is contained in:
parent
0b365061d1
commit
ebe1dc6dcd
Notes:
github-actions[bot]
2024-10-16 06:33:37 +00:00
Author: https://github.com/tcl3
Commit: ebe1dc6dcd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1818
1 changed files with 14 additions and 1 deletions
|
@ -483,11 +483,24 @@ void WebSocket::read_frame()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op_code == WebSocket::OpCode::ConnectionClose) {
|
if (op_code == WebSocket::OpCode::ConnectionClose) {
|
||||||
|
dbgln("Close connection with status: {}", to_underlying(m_state));
|
||||||
|
|
||||||
|
if (m_state == InternalState::Closing) {
|
||||||
|
dbgln("Close connection lmao");
|
||||||
|
set_state(WebSocket::InternalState::Closed);
|
||||||
|
notify_close(m_last_close_code, m_last_close_message, true);
|
||||||
|
discard_connection();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
send_frame(WebSocket::OpCode::ConnectionClose, {}, true);
|
||||||
|
set_state(WebSocket::InternalState::Closing);
|
||||||
if (payload.size() > 1) {
|
if (payload.size() > 1) {
|
||||||
m_last_close_code = (((u16)(payload[0] & 0xff) << 8) | ((u16)(payload[1] & 0xff)));
|
m_last_close_code = (((u16)(payload[0] & 0xff) << 8) | ((u16)(payload[1] & 0xff)));
|
||||||
m_last_close_message = ByteString(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
|
m_last_close_message = ByteString(ReadonlyBytes(payload.offset_pointer(2), payload.size() - 2));
|
||||||
|
} else {
|
||||||
|
m_last_close_code = 1000;
|
||||||
|
m_last_close_message = {};
|
||||||
}
|
}
|
||||||
set_state(WebSocket::InternalState::Closing);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (op_code == WebSocket::OpCode::Ping) {
|
if (op_code == WebSocket::OpCode::Ping) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue