1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 13:27:34 +00:00

WebServer: Allow the user to specify the base directory

This commit makes the WebServer accept a base path to serve.
This makes taking files out of the system significantly more simple
(depending on whom you ask).
This commit is contained in:
AnotherTest 2020-07-11 11:33:22 +04:30 committed by Andreas Kling
parent 7b5ffe67cf
commit 684b04e02a
3 changed files with 20 additions and 6 deletions

View file

@ -34,11 +34,12 @@ namespace WebServer {
class Client final : public Core::Object {
C_OBJECT(Client);
public:
void start();
private:
Client(NonnullRefPtr<Core::TCPSocket>, Core::Object* parent);
Client(NonnullRefPtr<Core::TCPSocket>, const String&, Core::Object* parent);
void handle_request(ByteBuffer);
void send_response(StringView, const HTTP::HttpRequest&);
@ -49,6 +50,7 @@ private:
void handle_directory_listing(const String& requested_path, const String& real_path, const HTTP::HttpRequest&);
NonnullRefPtr<Core::TCPSocket> m_socket;
String m_root_path;
};
}