]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/server.h
Use nullptr instead of 0 for pointers
[libs/net.git] / source / http / server.h
index 29b2b45a3d4cb95ad35a529139a64834e2e3c657..e6de22781d17077a8e26a66925231780de4c518d 100644 (file)
@@ -4,6 +4,7 @@
 #include <msp/core/refptr.h>
 #include <msp/io/eventdispatcher.h>
 #include <msp/net/streamserversocket.h>
+#include <msp/time/timedelta.h>
 
 namespace Msp {
 namespace Http {
@@ -21,11 +22,11 @@ private:
        {
                RefPtr<Net::StreamSocket> sock;
                std::string in_buf;
-               Request *request;
-               Response *response;
-               bool keepalive;
-               bool async;
-               bool stale;
+               Request *request = nullptr;
+               Response *response = nullptr;
+               bool keepalive = false;
+               bool async = false;
+               bool stale = false;
 
                Client(RefPtr<Net::StreamSocket>);
                ~Client();
@@ -34,16 +35,20 @@ private:
        Net::StreamServerSocket sock;
        std::list<Client> clients;
        std::map<Response *, Client *> responses;
-       IO::EventDispatcher *event_disp;
+       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 &);