mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
WebSocket: Avoid unnecessary IPC::Dictionary wrapper
We already have and use HashMap<DeprecatedString, DeprecatedString> nearly everywhere, which is equivalent.
This commit is contained in:
parent
9b9a38ec81
commit
d030f0fe9b
Notes:
sideshowbarker
2024-07-18 01:43:16 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/d030f0fe9b Pull-request: https://github.com/SerenityOS/serenity/pull/18928
4 changed files with 8 additions and 8 deletions
|
@ -16,10 +16,10 @@ WebSocketClient::WebSocketClient(NonnullOwnPtr<Core::LocalSocket> socket)
|
||||||
|
|
||||||
RefPtr<WebSocket> WebSocketClient::connect(const URL& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, HashMap<DeprecatedString, DeprecatedString> const& request_headers)
|
RefPtr<WebSocket> WebSocketClient::connect(const URL& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, HashMap<DeprecatedString, DeprecatedString> const& request_headers)
|
||||||
{
|
{
|
||||||
IPC::Dictionary header_dictionary;
|
auto headers_or_error = request_headers.clone();
|
||||||
for (auto& it : request_headers)
|
if (headers_or_error.is_error())
|
||||||
header_dictionary.add(it.key, it.value);
|
return nullptr;
|
||||||
auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, header_dictionary);
|
auto connection_id = IPCProxy::connect(url, origin, protocols, extensions, headers_or_error.release_value());
|
||||||
if (connection_id < 0)
|
if (connection_id < 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
auto connection = WebSocket::create_from_id({}, *this, connection_id);
|
auto connection = WebSocket::create_from_id({}, *this, connection_id);
|
||||||
|
|
|
@ -27,7 +27,7 @@ void ConnectionFromClient::die()
|
||||||
}
|
}
|
||||||
|
|
||||||
Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL const& url, DeprecatedString const& origin,
|
Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL const& url, DeprecatedString const& origin,
|
||||||
Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, IPC::Dictionary const& additional_request_headers)
|
Vector<DeprecatedString> const& protocols, Vector<DeprecatedString> const& extensions, HashMap<DeprecatedString, DeprecatedString> const& additional_request_headers)
|
||||||
{
|
{
|
||||||
if (!url.is_valid()) {
|
if (!url.is_valid()) {
|
||||||
dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url);
|
dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url);
|
||||||
|
@ -40,7 +40,7 @@ Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL con
|
||||||
connection_info.set_extensions(extensions);
|
connection_info.set_extensions(extensions);
|
||||||
|
|
||||||
Vector<ConnectionInfo::Header> headers;
|
Vector<ConnectionInfo::Header> headers;
|
||||||
for (auto const& header : additional_request_headers.entries()) {
|
for (auto const& header : additional_request_headers) {
|
||||||
headers.append({ header.key, header.value });
|
headers.append({ header.key, header.value });
|
||||||
}
|
}
|
||||||
connection_info.set_headers(headers);
|
connection_info.set_headers(headers);
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
explicit ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket>);
|
||||||
|
|
||||||
virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, DeprecatedString const&, Vector<DeprecatedString> const&, Vector<DeprecatedString> const&, IPC::Dictionary const&) override;
|
virtual Messages::WebSocketServer::ConnectResponse connect(URL const&, DeprecatedString const&, Vector<DeprecatedString> const&, Vector<DeprecatedString> const&, HashMap<DeprecatedString, DeprecatedString> const&) override;
|
||||||
virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override;
|
virtual Messages::WebSocketServer::ReadyStateResponse ready_state(i32) override;
|
||||||
virtual Messages::WebSocketServer::SubprotocolInUseResponse subprotocol_in_use(i32) override;
|
virtual Messages::WebSocketServer::SubprotocolInUseResponse subprotocol_in_use(i32) override;
|
||||||
virtual void send(i32, bool, ByteBuffer const&) override;
|
virtual void send(i32, bool, ByteBuffer const&) override;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
endpoint WebSocketServer
|
endpoint WebSocketServer
|
||||||
{
|
{
|
||||||
// Connection API
|
// Connection API
|
||||||
connect(URL url, DeprecatedString origin, Vector<DeprecatedString> protocols, Vector<DeprecatedString> extensions, IPC::Dictionary additional_request_headers) => (i32 connection_id)
|
connect(URL url, DeprecatedString origin, Vector<DeprecatedString> protocols, Vector<DeprecatedString> extensions, HashMap<DeprecatedString,DeprecatedString> additional_request_headers) => (i32 connection_id)
|
||||||
ready_state(i32 connection_id) => (u32 ready_state)
|
ready_state(i32 connection_id) => (u32 ready_state)
|
||||||
subprotocol_in_use(i32 connection_id) => (DeprecatedString subprotocol_in_use)
|
subprotocol_in_use(i32 connection_id) => (DeprecatedString subprotocol_in_use)
|
||||||
send(i32 connection_id, bool is_text, ByteBuffer data) =|
|
send(i32 connection_id, bool is_text, ByteBuffer data) =|
|
||||||
|
|
Loading…
Reference in a new issue