X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fserver.cpp;h=7caa0f5d025b6eb0e55db15f55cbf896aadf40ba;hb=a82a89a937d798b5b376d6a58917557a92c56988;hp=fc6d61f14c8c065e43bf951a4cc8f52b5a7eac48;hpb=065568e3a84b596ea15f80f67574ea7708d4e111;p=libs%2Fnet.git diff --git a/source/http/server.cpp b/source/http/server.cpp index fc6d61f..7caa0f5 100644 --- a/source/http/server.cpp +++ b/source/http/server.cpp @@ -1,6 +1,8 @@ #include +#include #include #include +#include #include #include #include @@ -106,7 +108,7 @@ void Server::client_data_available(Client &cl) cl.request = new Request(Request::parse(cl.in_buf)); string addr_str = cl.sock->get_peer_address().str(); - unsigned colon = addr_str.find(':'); + string::size_type colon = addr_str.find(':'); cl.request->set_header("-Client-Host", addr_str.substr(0, colon)); if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST") @@ -123,7 +125,8 @@ void Server::client_data_available(Client &cl) catch(const exception &e) { response = new Response(BAD_REQUEST); - response->add_content(e.what()); + response->add_content(format("An error occurred while parsing request headers:\ntype: %s\nwhat: %s", + Debug::demangle(typeid(e).name()), e.what())); } cl.in_buf = string(); } @@ -164,7 +167,8 @@ void Server::client_data_available(Client &cl) responses.erase(cl.response); cl.response = 0; response = new Response(INTERNAL_ERROR); - response->add_content(e.what()); + response->add_content(format("An error occurred while processing the request:\ntype: %s\nwhat: %s", + Debug::demangle(typeid(e).name()), e.what())); } }