]> git.tdb.fi Git - libs/net.git/blobdiff - source/server.cpp
Use maputils.h
[libs/net.git] / source / server.cpp
index e0aedf28c1b16d0cb6c451c33a8b7bd5d290ce23..259d13b087598d5ae602f1c4b16e7ec6ed24259e 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of libmsphttp
-Copyright © 2008  Mikkosoft Productions, Mikko Rasa
-Distributed under the LGPL
-*/
-
 #include <exception>
 #include <msp/core/refptr.h>
 #include <msp/net/inet.h>
@@ -62,7 +55,6 @@ void Server::submit_response(Response &resp)
        if(cl.async)
        {
                cl.sock->write(resp.str());
-               cl.sock->close();
                cl.stale = true;
        }
 }
@@ -106,7 +98,7 @@ void Server::client_data_available(Client &cl)
                                if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST")
                                {
                                        response = new Response(NOT_IMPLEMENTED);
-                                       response->add_content("Method not implemented");
+                                       response->add_content("Method not implemented\n");
                                }
                        }
                        catch(const exception &e)
@@ -138,7 +130,7 @@ void Server::client_data_available(Client &cl)
                                if(response->get_status()==NONE)
                                {
                                        response = new Response(NOT_FOUND);
-                                       response->add_content("The requested resource was not found");
+                                       response->add_content("The requested resource was not found\n");
                                }
                        }
                }
@@ -153,7 +145,6 @@ void Server::client_data_available(Client &cl)
        if(response)
        {
                cl.sock->write(response->str());
-               cl.sock->close();
                cl.stale = true;
        }
 }
@@ -169,7 +160,8 @@ Server::Client &Server::get_client_by_response(Response &resp)
                if(i->response==&resp)
                        return *i;
 
-       throw InvalidParameterValue("Response does not belong to any client");
+       // XXX Do this differently
+       throw invalid_argument("Response does not belong to any client");
 }