1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00
serenity/Userland/Services/WebServer/Client.h
Max Wipfli 2d18d3f329 WebServer: Use canonical reasons phrases for error responses
This changes the Client::set_error_response() to not take a "message"
anymore. It now uses the canonical reason phrase which is derived from
the response code.
2021-06-11 11:37:15 +02:00

36 lines
968 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>, String const&, 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;
String m_root_path;
};
}