/* * Copyright (c) 2022, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #define AK_DONT_REPLACE_STD #include #include #include class RequestManagerQt : public QObject , public Web::ResourceLoaderConnector { Q_OBJECT public: static NonnullRefPtr create() { return adopt_ref(*new RequestManagerQt()); } virtual ~RequestManagerQt() override { } virtual void prefetch_dns(AK::URL const&) override { } virtual void preconnect(AK::URL const&) override { } virtual RefPtr start_request(String const& method, AK::URL const&, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override; private slots: void reply_finished(QNetworkReply*); private: RequestManagerQt(); class Request : public Web::ResourceLoaderConnectorRequest { public: static ErrorOr> create(QNetworkAccessManager& qnam, String const& method, AK::URL const& url, HashMap const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&); virtual ~Request() override; virtual void set_should_buffer_all_input(bool) override { } virtual bool stop() override { return false; } virtual void stream_into(Core::Stream::Stream&) override { } void did_finish(); QNetworkReply& reply() { return m_reply; } private: Request(QNetworkReply&); QNetworkReply& m_reply; }; HashMap> m_pending; QNetworkAccessManager* m_qnam { nullptr }; };