ladybird/Userland/Libraries/LibWebView/RequestServerAdapter.h
Shannon Booth e800605ad3 AK+LibURL: Move AK::URL into a new URL library
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.
2024-03-18 14:06:28 -04:00

56 lines
1.9 KiB
C++

/*
* Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibURL/URL.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/WebSockets/WebSocket.h>
namespace Protocol {
class Request;
class RequestClient;
}
namespace WebView {
class RequestServerRequestAdapter
: public Web::ResourceLoaderConnectorRequest
, public Weakable<RequestServerRequestAdapter> {
public:
static ErrorOr<NonnullRefPtr<RequestServerRequestAdapter>> try_create(NonnullRefPtr<Protocol::Request>);
virtual ~RequestServerRequestAdapter() override;
virtual void set_should_buffer_all_input(bool) override;
virtual bool stop() override;
virtual void stream_into(Stream&) override;
private:
RequestServerRequestAdapter(NonnullRefPtr<Protocol::Request>);
NonnullRefPtr<Protocol::Request> m_request;
};
class RequestServerAdapter : public Web::ResourceLoaderConnector {
public:
explicit RequestServerAdapter(NonnullRefPtr<Protocol::RequestClient> protocol_client);
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create(NonnullRefPtr<Protocol::RequestClient>);
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create();
virtual ~RequestServerAdapter() override;
virtual void prefetch_dns(URL::URL const& url) override;
virtual void preconnect(URL::URL const& url) override;
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(ByteString const& method, URL::URL const&, HashMap<ByteString, ByteString> const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) override;
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> websocket_connect(const URL::URL&, ByteString const& origin, Vector<ByteString> const& protocols) override;
private:
RefPtr<Protocol::RequestClient> m_protocol_client;
};
}