/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace WebServer { class Client final : public Core::Object { C_OBJECT(Client); public: void start(); private: Client(Core::Stream::BufferedTCPSocket, Core::Object* parent); ErrorOr handle_request(ReadonlyBytes); ErrorOr send_response(InputStream&, HTTP::HttpRequest const&, String const& content_type); ErrorOr send_redirect(StringView redirect, HTTP::HttpRequest const&); ErrorOr send_error_response(unsigned code, HTTP::HttpRequest const&, Vector const& headers = {}); void die(); void log_response(unsigned code, HTTP::HttpRequest const&); ErrorOr handle_directory_listing(String const& requested_path, String const& real_path, HTTP::HttpRequest const&); bool verify_credentials(Vector const&); Core::Stream::BufferedTCPSocket m_socket; }; }