diff --git a/Userland/Libraries/LibProtocol/WebSocketClient.cpp b/Userland/Libraries/LibProtocol/WebSocketClient.cpp index 457e18d7114..652bec081fd 100644 --- a/Userland/Libraries/LibProtocol/WebSocketClient.cpp +++ b/Userland/Libraries/LibProtocol/WebSocketClient.cpp @@ -16,10 +16,10 @@ WebSocketClient::WebSocketClient(NonnullOwnPtr socket) RefPtr WebSocketClient::connect(const URL& url, DeprecatedString const& origin, Vector const& protocols, Vector const& extensions, HashMap const& request_headers) { - IPC::Dictionary header_dictionary; - for (auto& it : request_headers) - header_dictionary.add(it.key, it.value); - auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary); + auto headers_or_error = request_headers.clone(); + if (headers_or_error.is_error()) + return nullptr; + auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, headers_or_error.release_value()); if (connection_id < 0) return nullptr; auto connection = WebSocket::create_from_id({}, *this, connection_id); diff --git a/Userland/Services/WebSocket/ConnectionFromClient.cpp b/Userland/Services/WebSocket/ConnectionFromClient.cpp index 4d02d62ce45..c679d867fe5 100644 --- a/Userland/Services/WebSocket/ConnectionFromClient.cpp +++ b/Userland/Services/WebSocket/ConnectionFromClient.cpp @@ -27,7 +27,7 @@ void ConnectionFromClient::die() } Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL const& url, DeprecatedString const& origin, - Vector const& protocols, Vector const& extensions, IPC::Dictionary const& additional_request_headers) + Vector const& protocols, Vector const& extensions, HashMap const& additional_request_headers) { if (!url.is_valid()) { dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url); @@ -40,7 +40,7 @@ Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL con connection_info.set_extensions(extensions); Vector headers; - for (auto const& header : additional_request_headers.entries()) { + for (auto const& header : additional_request_headers) { headers.append({ header.key, header.value }); } connection_info.set_headers(headers); diff --git a/Userland/Services/WebSocket/ConnectionFromClient.h b/Userland/Services/WebSocket/ConnectionFromClient.h index 14f8b9c47bd..04d77ed8bca 100644 --- a/Userland/Services/WebSocket/ConnectionFromClient.h +++ b/Userland/Services/WebSocket/ConnectionFromClient.h @@ -26,7 +26,7 @@ public: private: explicit ConnectionFromClient(NonnullOwnPtr); - virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, DeprecatedString const&, Vector const&, Vector const&, IPC::Dictionary const&) override; + virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, DeprecatedString const&, Vector const&, Vector const&, HashMap const&) override; virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override; virtual Messages::WebSocketServer::SubprotocolInUseResponse subprotocol_in_use(i32) override; virtual void send(i32, bool, ByteBuffer const&) override; diff --git a/Userland/Services/WebSocket/WebSocketServer.ipc b/Userland/Services/WebSocket/WebSocketServer.ipc index 5b5bc7aa8bc..9db54bc4277 100644 --- a/Userland/Services/WebSocket/WebSocketServer.ipc +++ b/Userland/Services/WebSocket/WebSocketServer.ipc @@ -3,7 +3,7 @@ endpoint WebSocketServer { // Connection API - connect(URL url, DeprecatedString origin, Vector protocols, Vector extensions, IPC::Dictionary additional_request_headers) => (i32 connection_id) + connect(URL url, DeprecatedString origin, Vector protocols, Vector extensions, HashMap additional_request_headers) => (i32 connection_id) ready_state(i32 connection_id) => (u32 ready_state) subprotocol_in_use(i32 connection_id) => (DeprecatedString subprotocol_in_use) send(i32 connection_id, bool is_text, ByteBuffer data) =|