mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-05 01:42:54 +00:00
This URL library ends up being a relatively fundamental base library of the system, as LibCore depends on LibURL. This change has two main benefits: * Moving AK back more towards being an agnostic library that can be used between the kernel and userspace. URL has never really fit that description - and is not used in the kernel. * URL _should_ depend on LibUnicode, as it needs punnycode support. However, it's not really possible to do this inside of AK as it can't depend on any external library. This change brings us a little closer to being able to do that, but unfortunately we aren't there quite yet, as the code generators depend on LibCore.
55 lines
2.2 KiB
C++
55 lines
2.2 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/HashMap.h>
|
|
#include <LibIPC/ConnectionToServer.h>
|
|
#include <LibProtocol/WebSocket.h>
|
|
#include <LibWebSocket/WebSocket.h>
|
|
#include <RequestServer/RequestClientEndpoint.h>
|
|
#include <RequestServer/RequestServerEndpoint.h>
|
|
|
|
namespace Protocol {
|
|
|
|
class Request;
|
|
|
|
class RequestClient final
|
|
: public IPC::ConnectionToServer<RequestClientEndpoint, RequestServerEndpoint>
|
|
, public RequestClientEndpoint {
|
|
IPC_CLIENT_CONNECTION(RequestClient, "/tmp/session/%sid/portal/request"sv)
|
|
|
|
public:
|
|
explicit RequestClient(NonnullOwnPtr<Core::LocalSocket>);
|
|
|
|
template<typename RequestHashMapTraits = Traits<ByteString>>
|
|
RefPtr<Request> start_request(ByteString const& method, URL::URL const&, HashMap<ByteString, ByteString, RequestHashMapTraits> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {});
|
|
|
|
RefPtr<WebSocket> websocket_connect(const URL::URL&, ByteString const& origin = {}, Vector<ByteString> const& protocols = {}, Vector<ByteString> const& extensions = {}, HashMap<ByteString, ByteString> const& request_headers = {});
|
|
|
|
void ensure_connection(URL::URL const&, ::RequestServer::CacheLevel);
|
|
|
|
bool stop_request(Badge<Request>, Request&);
|
|
bool set_certificate(Badge<Request>, Request&, ByteString, ByteString);
|
|
|
|
private:
|
|
virtual void request_started(i32, IPC::File const&) override;
|
|
virtual void request_progress(i32, Optional<u64> const&, u64) override;
|
|
virtual void request_finished(i32, bool, u64) override;
|
|
virtual void certificate_requested(i32) override;
|
|
virtual void headers_became_available(i32, HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const&, Optional<u32> const&) override;
|
|
|
|
virtual void websocket_connected(i32) override;
|
|
virtual void websocket_received(i32, bool, ByteBuffer const&) override;
|
|
virtual void websocket_errored(i32, i32) override;
|
|
virtual void websocket_closed(i32, u16, ByteString const&, bool) override;
|
|
virtual void websocket_certificate_requested(i32) override;
|
|
|
|
HashMap<i32, RefPtr<Request>> m_requests;
|
|
HashMap<i32, NonnullRefPtr<WebSocket>> m_websockets;
|
|
};
|
|
|
|
}
|