LibWeb/WebSocket: Allow sending binary blob data over a websocket

(cherry picked from commit 4ccc52e921a5b17c6f6ec67dec7c0dff46ac7884)
This commit is contained in:
Tim Ledbetter 2024-09-25 09:57:57 +01:00 committed by Nico Weber
parent 1df82e4c49
commit eb3219781d

View file

@ -287,7 +287,11 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
if (m_binary_type == "blob") {
// type indicates that the data is Binary and binaryType is "blob"
TODO();
HTML::MessageEventInit event_init;
event_init.data = FileAPI::Blob::create(realm(), message, "text/plain;charset=utf-8"_string);
event_init.origin = url().release_value_but_fixme_should_propagate_errors();
dispatch_event(HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init));
return;
} else if (m_binary_type == "arraybuffer") {
// type indicates that the data is Binary and binaryType is "arraybuffer"
HTML::MessageEventInit event_init;