summaryrefslogtreecommitdiff
path: root/Servers/WebServer/Client.h
blob: c8d5ec3d3ffc16282d37b6e3c824c6e28fe1c0a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once

#include <LibCore/Object.h>
#include <LibCore/TCPSocket.h>

namespace Core {
class HttpRequest;
}

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(ByteBuffer);
    void send_error_response(unsigned code, const StringView& message, const Core::HttpRequest&);
    void die();
    void log_response(unsigned code, const Core::HttpRequest&);

    NonnullRefPtr<Core::TCPSocket> m_socket;
};

}