]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/server.cpp
Use nullptr instead of 0 for pointers
[libs/net.git] / source / http / server.cpp
index 6055f008e4ff13328a6bf5409584a7e96f682458..a7435d330350b41e60416dbc3eb632d840b742ab 100644 (file)
@@ -18,13 +18,11 @@ namespace Msp {
 namespace Http {
 
 Server::Server():
-       sock(Net::INET6),
-       event_disp(0)
+       sock(Net::INET6)
 { }
 
 Server::Server(unsigned port):
-       sock(Net::INET6),
-       event_disp(0)
+       sock(Net::INET6)
 {
        listen(port);
 }
@@ -95,7 +93,7 @@ void Server::close_connections(const Time::TimeDelta &timeout)
        while(!clients.empty() && poller.poll(timeout))
        {
                for(const IO::Poller::PolledObject &p: poller.get_result())
-                       for(list<Client>::iterator j=clients.begin(); j!=clients.end(); ++j)
+                       for(auto j=clients.begin(); j!=clients.end(); ++j)
                                if(j->sock.get()==p.object)
                                {
                                        poller.set_object(*j->sock, IO::P_NONE);
@@ -117,7 +115,7 @@ void Server::data_available()
 
 void Server::client_data_available(Client &cl)
 {
-       for(list<Client>::iterator i=clients.begin(); i!=clients.end(); ++i)
+       for(auto i=clients.begin(); i!=clients.end(); ++i)
                if(i->stale && &*i!=&cl)
                {
                        clients.erase(i);
@@ -194,7 +192,7 @@ void Server::client_data_available(Client &cl)
                        else
                        {
                                responses.erase(cl.response);
-                               cl.response = 0;
+                               cl.response = nullptr;
                                if(response->get_status()==NONE)
                                {
                                        response = new Response(NOT_FOUND);
@@ -205,7 +203,7 @@ void Server::client_data_available(Client &cl)
                catch(const exception &e)
                {
                        responses.erase(cl.response);
-                       cl.response = 0;
+                       cl.response = nullptr;
                        response = new Response(INTERNAL_ERROR);
                        response->add_content(format("An error occurred while processing the request:\ntype: %s\nwhat: %s",
                                Debug::demangle(typeid(e).name()), e.what()));
@@ -235,9 +233,9 @@ void Server::send_response(Client &cl, Response &resp)
        if(cl.keepalive)
        {
                delete cl.request;
-               cl.request = 0;
+               cl.request = nullptr;
                delete cl.response;
-               cl.response = 0;
+               cl.response = nullptr;
        }
        else
        {
@@ -258,12 +256,7 @@ Server::Client &Server::get_client_by_response(Response &resp)
 
 
 Server::Client::Client(RefPtr<Net::StreamSocket> s):
-       sock(s),
-       request(0),
-       response(0),
-       keepalive(false),
-       async(false),
-       stale(false)
+       sock(s)
 { }
 
 Server::Client::~Client()