* HTTPProxy.cpp : migrate HTTPRequestFailed() to new http classes

This commit is contained in:
hagen 2016-06-27 01:30:00 +00:00
parent 6f77c6f3f4
commit 727068cc4b

View File

@ -106,14 +106,13 @@ namespace proxy {
//TODO: handle this apropriately
void HTTPReqHandler::HTTPRequestFailed(const char *message)
{
std::size_t size = std::strlen(message);
std::stringstream ss;
ss << "HTTP/1.0 500 Internal Server Error\r\n"
<< "Content-Type: text/plain\r\n";
ss << "Content-Length: " << std::to_string(size + 2) << "\r\n"
<< "\r\n"; /* end of headers */
ss << message << "\r\n";
std::string response = ss.str();
i2p::http::HTTPRes res;
res.code = 500;
res.add_header("Content-Type", "text/plain");
res.add_header("Connection", "close");
res.body = message;
res.body += "\r\n";
std::string response = res.to_string();
boost::asio::async_write(*m_sock, boost::asio::buffer(response),
std::bind(&HTTPReqHandler::SentHTTPFailed, shared_from_this(), std::placeholders::_1));
}