X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fserver.h;h=dd8b2c6c88589bd4b453b9fc48c7275fee277b9c;hb=ede42d5bb352841e2e425972e12b8ef31ddf2123;hp=41894db99d6141dc89c901c354d06b4f25ca25b3;hpb=cf8d2e48581eeb8f1b83e8c48321a0bc2ffa6d83;p=libs%2Fnet.git diff --git a/source/http/server.h b/source/http/server.h index 41894db..dd8b2c6 100644 --- a/source/http/server.h +++ b/source/http/server.h @@ -1,9 +1,9 @@ #ifndef MSP_HTTP_SERVER_H_ #define MSP_HTTP_SERVER_H_ -#include #include #include +#include namespace Msp { namespace Http { @@ -19,30 +19,38 @@ public: private: struct Client { - RefPtr sock; + std::unique_ptr sock; std::string in_buf; - Request *request; - Response *response; - bool async; - bool stale; + std::unique_ptr request; + std::unique_ptr response; + bool keepalive = false; + bool async = false; + bool stale = false; - Client(RefPtr); - ~Client(); + Client(std::unique_ptr); }; Net::StreamServerSocket sock; std::list clients; - IO::EventDispatcher *event_disp; + std::map responses; + IO::EventDispatcher *event_disp = nullptr; public: + Server(); Server(unsigned); + ~Server(); + + void listen(unsigned); unsigned get_port() const; void use_event_dispatcher(IO::EventDispatcher *); void delay_response(Response &); void submit_response(Response &); + void cancel_keepalive(Response &); + void close_connections(const Time::TimeDelta &); private: void data_available(); void client_data_available(Client &); + void send_response(Client &, Response &); void client_end_of_file(Client &); Client &get_client_by_response(Response &); };