mirror of
https://github.com/RGBCube/serenity
synced 2026-01-15 10:21:00 +00:00
This server listens on port 8000 and serves HTML files from /www. It's very simple and quite naive, but I think we can start here and build our way to something pretty neat. Work towards #792.
28 lines
571 B
C++
28 lines
571 B
C++
#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;
|
|
};
|
|
|
|
}
|