2022-04-30 13:06:30 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Function.h>
|
2024-03-18 06:22:27 +03:00
|
|
|
#include <LibURL/URL.h>
|
2022-04-30 13:06:30 +03:00
|
|
|
#include <LibWeb/Loader/ResourceLoader.h>
|
2024-03-06 03:50:52 +03:00
|
|
|
#include <LibWeb/WebSockets/WebSocket.h>
|
2022-04-30 13:06:30 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-05-24 18:37:02 +03:00
|
|
|
virtual void set_buffered_request_finished_callback(Protocol::Request::BufferedRequestFinished) override;
|
|
|
|
virtual void set_unbuffered_request_callbacks(Protocol::Request::HeadersReceived, Protocol::Request::DataReceived, Protocol::Request::RequestFinished) override;
|
2022-04-30 13:06:30 +03:00
|
|
|
virtual bool stop() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
RequestServerRequestAdapter(NonnullRefPtr<Protocol::Request>);
|
|
|
|
NonnullRefPtr<Protocol::Request> m_request;
|
|
|
|
};
|
|
|
|
|
|
|
|
class RequestServerAdapter : public Web::ResourceLoaderConnector {
|
|
|
|
public:
|
2023-08-01 23:41:13 +03:00
|
|
|
explicit RequestServerAdapter(NonnullRefPtr<Protocol::RequestClient> protocol_client);
|
|
|
|
|
|
|
|
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create(NonnullRefPtr<Protocol::RequestClient>);
|
2022-04-30 13:06:30 +03:00
|
|
|
static ErrorOr<NonnullRefPtr<RequestServerAdapter>> try_create();
|
|
|
|
virtual ~RequestServerAdapter() override;
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
virtual void prefetch_dns(URL::URL const& url) override;
|
|
|
|
virtual void preconnect(URL::URL const& url) override;
|
2022-04-30 13:06:30 +03:00
|
|
|
|
2024-06-09 14:46:04 +03:00
|
|
|
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(ByteString const& method, URL::URL const&, HTTP::HeaderMap const& request_headers = {}, ReadonlyBytes request_body = {}, Core::ProxyData const& = {}) override;
|
2024-03-18 06:22:27 +03:00
|
|
|
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> websocket_connect(const URL::URL&, ByteString const& origin, Vector<ByteString> const& protocols) override;
|
2022-04-30 13:06:30 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
RefPtr<Protocol::RequestClient> m_protocol_client;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|