1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:28:11 +00:00
serenity/Userland/Services/WebServer/Client.h
Max Wipfli e77ca79897 WebServer: Move server configuration into WebServer::Configuration
This moves the configuration of the web server, which currently only
consists of the root path, into a new class, Configuration. Since the
configuration is global and not per client, it is accessed by a
singleton getter.

This change simplifies future extensions of the configurable parameters.
2021-06-11 11:37:15 +02:00

35 lines
929 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibCore/Object.h>
#include <LibCore/TCPSocket.h>
#include <LibHTTP/Forward.h>
namespace WebServer {
class Client final : public Core::Object {
C_OBJECT(Client);
public:
void start();
private:
Client(NonnullRefPtr<Core::TCPSocket>, 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&);
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&);
NonnullRefPtr<Core::TCPSocket> m_socket;
};
}