diff options
author | DexesTTP <dexes.ttp@gmail.com> | 2021-04-23 22:45:52 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-04-25 19:04:34 +0200 |
commit | 71d27abb97acc656256f3fef6d2a67878d520f12 (patch) | |
tree | 64fb2a7ee9df5398e3c09195ea2f388230feca91 /Userland/Services/RequestServer/GeminiProtocol.cpp | |
parent | 22413ef729ffe995c5ef3a9f8fb69567ed913980 (diff) | |
download | serenity-71d27abb97acc656256f3fef6d2a67878d520f12.zip |
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.
Diffstat (limited to 'Userland/Services/RequestServer/GeminiProtocol.cpp')
-rw-r--r-- | Userland/Services/RequestServer/GeminiProtocol.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Userland/Services/RequestServer/GeminiProtocol.cpp b/Userland/Services/RequestServer/GeminiProtocol.cpp new file mode 100644 index 0000000000..243dddce5d --- /dev/null +++ b/Userland/Services/RequestServer/GeminiProtocol.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020, The SerenityOS developers. + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <LibGemini/GeminiJob.h> +#include <LibGemini/GeminiRequest.h> +#include <RequestServer/GeminiProtocol.h> +#include <RequestServer/GeminiRequest.h> +#include <fcntl.h> + +namespace RequestServer { + +GeminiProtocol::GeminiProtocol() + : Protocol("gemini") +{ +} + +GeminiProtocol::~GeminiProtocol() +{ +} + +OwnPtr<Request> GeminiProtocol::start_request(ClientConnection& client, const String&, const URL& url, const HashMap<String, String>&, ReadonlyBytes) +{ + Gemini::GeminiRequest request; + request.set_url(url); + + auto pipe_result = get_pipe_for_request(); + if (pipe_result.is_error()) + return {}; + + auto output_stream = make<OutputFileStream>(pipe_result.value().write_fd); + output_stream->make_unbuffered(); + auto job = Gemini::GeminiJob::construct(request, *output_stream); + auto protocol_request = GeminiRequest::create_with_job({}, client, (Gemini::GeminiJob&)*job, move(output_stream)); + protocol_request->set_request_fd(pipe_result.value().read_fd); + job->start(); + return protocol_request; +} + +} |