Browse Source

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

pull/551/head
hagen 8 years ago
parent
commit
727068cc4b
  1. 15
      HTTPProxy.cpp

15
HTTPProxy.cpp

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

Loading…
Cancel
Save