X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fserver.cpp;h=a7435d330350b41e60416dbc3eb632d840b742ab;hb=3ab65d35cfd696002e09768a38f98e6a2e1ade81;hp=6055f008e4ff13328a6bf5409584a7e96f682458;hpb=62ea6954a91568c900ad8155999bea264dfa72f3;p=libs%2Fnet.git diff --git a/source/http/server.cpp b/source/http/server.cpp index 6055f00..a7435d3 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -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::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::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 s): - sock(s), - request(0), - response(0), - keepalive(false), - async(false), - stale(false) + sock(s) { } Server::Client::~Client()