crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

senderrorpage.cc (981B)


      1 #include "httpdispatcher"
      2 
      3 void HttpDispatcher::senderrorpage(string const &reason) {
      4     PROFILE("HttpDispatcher::senderrorpage");
      5     
      6     msg("Sending error page to client: '" << reason << "'\n");
      7     try {
      8 	string txt =
      9 	    "<html>\n"
     10 	    " <head>\n"
     11 	    "  <title>Internal Server Error</title>\n"
     12 	    " </head>\n"
     13 	    " <body>\n"
     14 	    "  <h1>Internal Server Error</h1>\n"
     15 	    "  You request could not be completed. Please retry later.<p/>"
     16 	    "  (" + reason + ")\n"
     17 	    " </body>\n"
     18 	    "</html>\n";
     19 	ostringstream mess;
     20 	mess <<
     21 	    "HTTP/1.0 502 Internal Server Error\r\n"
     22 	    "Content-Length: " << txt.size() << "\r\n"
     23 	    "XR-Reason: " << reason << "\r\n"
     24 	    "\r\n" <<
     25 	    txt;
     26 	Netbuffer buf(mess.str());
     27 	buf.netwrite(clientfd(), config.client_write_timeout());
     28     } catch (Error const &e) {
     29 	// Silently discard, we are not interested in errors
     30 	// that ocur when an error page is being sent
     31 	msg (e.what() << " (while sending error page)\n");
     32     }
     33 }