summaryrefslogtreecommitdiff
path: root/Userland/Services/WebServer/Client.h
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-09-12 11:55:40 +0000
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-12-16 22:21:35 +0330
commitdfdb52efa753d21767492eb1e812245a2141c82e (patch)
treedbf22ebd3b69670eba6a5ed6bc74278b902682a1 /Userland/Services/WebServer/Client.h
parent2341b0159a7ed86f4665df21df1357c16f3081f3 (diff)
downloadserenity-dfdb52efa753d21767492eb1e812245a2141c82e.zip
LibCore+Userland: Convert TCPServer to use the Serenity Stream API
This is intended as a real-usecase test of the Serenity Stream API, and seemed like a good candidate due to its low amount of users.
Diffstat (limited to 'Userland/Services/WebServer/Client.h')
-rw-r--r--Userland/Services/WebServer/Client.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/Userland/Services/WebServer/Client.h b/Userland/Services/WebServer/Client.h
index 5318776b46..a8a306f3ed 100644
--- a/Userland/Services/WebServer/Client.h
+++ b/Userland/Services/WebServer/Client.h
@@ -7,8 +7,9 @@
#pragma once
#include <LibCore/Object.h>
-#include <LibCore/TCPSocket.h>
+#include <LibCore/Stream.h>
#include <LibHTTP/Forward.h>
+#include <LibHTTP/HttpRequest.h>
namespace WebServer {
@@ -19,18 +20,18 @@ public:
void start();
private:
- Client(NonnullRefPtr<Core::TCPSocket>, Core::Object* parent);
+ Client(Core::Stream::BufferedTCPSocket, Core::Object* parent);
- void handle_request(ReadonlyBytes);
- void send_response(InputStream&, HTTP::HttpRequest const&, String const& content_type);
- void send_redirect(StringView redirect, HTTP::HttpRequest const&);
- void send_error_response(unsigned code, HTTP::HttpRequest const&, Vector<String> const& headers = {});
+ ErrorOr<bool> handle_request(ReadonlyBytes);
+ ErrorOr<void> send_response(InputStream&, HTTP::HttpRequest const&, String const& content_type);
+ ErrorOr<void> send_redirect(StringView redirect, HTTP::HttpRequest const&);
+ ErrorOr<void> send_error_response(unsigned code, HTTP::HttpRequest const&, Vector<String> const& headers = {});
void die();
void log_response(unsigned code, HTTP::HttpRequest const&);
- void handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const&);
+ ErrorOr<void> handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const&);
bool verify_credentials(Vector<HTTP::HttpRequest::Header> const&);
- NonnullRefPtr<Core::TCPSocket> m_socket;
+ Core::Stream::BufferedTCPSocket m_socket;
};
}