ladybird/Userland/Libraries/LibProtocol/RequestClient.h
DexesTTP 71d27abb97 Services: Rename ProtocolServer to RequestServer
The current ProtocolServer was really only used for requests, and with
the recent introduction of the WebSocket service, long-lasting
connections with another server are not part of it. To better reflect
this, this commit renames it to RequestServer.

This commit also changes the existing 'protocol' portal to 'request',
the existing 'protocol' user and group to 'request', and most mentions
of the 'download' aspect of the request to 'request' when relevant, to
make everything consistent across the system.

Note that LibProtocol still exists as-is, but the more generic Client
class and the more specific Download class have both been renamed to a
more accurate RequestClient and Request to match the new names.

This commit only change names, not behaviors.
2021-04-25 19:04:34 +02:00

44 lines
1.4 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/ServerConnection.h>
#include <RequestServer/RequestClientEndpoint.h>
#include <RequestServer/RequestServerEndpoint.h>
namespace Protocol {
class Request;
class RequestClient
: public IPC::ServerConnection<RequestClientEndpoint, RequestServerEndpoint>
, public RequestClientEndpoint {
C_OBJECT(RequestClient);
public:
virtual void handshake() override;
bool is_supported_protocol(const String&);
template<typename RequestHashMapTraits = Traits<String>>
RefPtr<Request> start_request(const String& method, const String& url, const HashMap<String, String, RequestHashMapTraits>& request_headers = {}, ReadonlyBytes request_body = {});
bool stop_request(Badge<Request>, Request&);
bool set_certificate(Badge<Request>, Request&, String, String);
private:
RequestClient();
virtual void handle(const Messages::RequestClient::RequestProgress&) override;
virtual void handle(const Messages::RequestClient::RequestFinished&) override;
virtual OwnPtr<Messages::RequestClient::CertificateRequestedResponse> handle(const Messages::RequestClient::CertificateRequested&) override;
virtual void handle(const Messages::RequestClient::HeadersBecameAvailable&) override;
HashMap<i32, RefPtr<Request>> m_requests;
};
}