mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-28 21:54:40 +03: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
@ -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)
|
||||
{
|
||||
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);
|
||||
|
@ -27,7 +27,7 @@ void ConnectionFromClient::die()
|
||||
}
|
||||
|
||||
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()) {
|
||||
dbgln("WebSocket::Connect: Invalid URL requested: '{}'", url);
|
||||
@ -40,7 +40,7 @@ Messages::WebSocketServer::ConnectResponse ConnectionFromClient::connect(URL con
|
||||
connection_info.set_extensions(extensions);
|
||||
|
||||
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 });
|
||||
}
|
||||
connection_info.set_headers(headers);
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
private:
|
||||
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::SubprotocolInUseResponse subprotocol_in_use(i32) override;
|
||||
virtual void send(i32, bool, ByteBuffer const&) override;
|
||||
|
@ -3,7 +3,7 @@
|
||||
endpoint WebSocketServer
|
||||
{
|
||||
// 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)
|
||||
subprotocol_in_use(i32 connection_id) => (DeprecatedString subprotocol_in_use)
|
||||
send(i32 connection_id, bool is_text, ByteBuffer data) =|
|
||||
|
Loading…
Reference in New Issue
Block a user