mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
* I2PControl.cpp : SendResponse() third arg now std::string &
This commit is contained in:
parent
ebc411bbbd
commit
0e1765e045
|
@ -192,6 +192,7 @@ namespace client
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
bool isHtml = !memcmp (buf->data (), "POST", 4);
|
bool isHtml = !memcmp (buf->data (), "POST", 4);
|
||||||
|
std::string content;
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss.write (buf->data (), bytes_transferred);
|
ss.write (buf->data (), bytes_transferred);
|
||||||
if (isHtml)
|
if (isHtml)
|
||||||
|
@ -242,7 +243,8 @@ namespace client
|
||||||
response << "\"jsonrpc\":\"2.0\"}";
|
response << "\"jsonrpc\":\"2.0\"}";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SendResponse (socket, buf, response, isHtml);
|
content = response.str();
|
||||||
|
SendResponse (socket, buf, content, isHtml);
|
||||||
}
|
}
|
||||||
catch (std::exception& ex)
|
catch (std::exception& ex)
|
||||||
{
|
{
|
||||||
|
@ -275,23 +277,19 @@ namespace client
|
||||||
}
|
}
|
||||||
|
|
||||||
void I2PControlService::SendResponse (std::shared_ptr<ssl_socket> socket,
|
void I2PControlService::SendResponse (std::shared_ptr<ssl_socket> socket,
|
||||||
std::shared_ptr<I2PControlBuffer> buf, std::ostringstream& response, bool isHtml)
|
std::shared_ptr<I2PControlBuffer> buf, std::string& content, bool isHtml)
|
||||||
{
|
{
|
||||||
std::string out;
|
|
||||||
std::size_t len;
|
|
||||||
if (isHtml) {
|
if (isHtml) {
|
||||||
i2p::http::HTTPRes res;
|
i2p::http::HTTPRes res;
|
||||||
res.code = 200;
|
res.code = 200;
|
||||||
res.add_header("Content-Type", "application/json");
|
res.add_header("Content-Type", "application/json");
|
||||||
res.add_header("Connection", "close");
|
res.add_header("Connection", "close");
|
||||||
res.body = response.str();
|
res.body = content;
|
||||||
out = res.to_string();
|
std::string tmp = res.to_string();
|
||||||
} else {
|
content = tmp;
|
||||||
out = response.str();
|
|
||||||
}
|
}
|
||||||
std::copy(out.begin(), out.end(), buf->begin());
|
std::copy(content.begin(), content.end(), buf->begin());
|
||||||
len = out.length();
|
boost::asio::async_write (*socket, boost::asio::buffer (buf->data (), content.length()),
|
||||||
boost::asio::async_write (*socket, boost::asio::buffer (buf->data (), len),
|
|
||||||
boost::asio::transfer_all (),
|
boost::asio::transfer_all (),
|
||||||
std::bind(&I2PControlService::HandleResponseSent, this,
|
std::bind(&I2PControlService::HandleResponseSent, this,
|
||||||
std::placeholders::_1, std::placeholders::_2, socket, buf));
|
std::placeholders::_1, std::placeholders::_2, socket, buf));
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace client
|
||||||
void HandleRequestReceived (const boost::system::error_code& ecode, size_t bytes_transferred,
|
void HandleRequestReceived (const boost::system::error_code& ecode, size_t bytes_transferred,
|
||||||
std::shared_ptr<ssl_socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
std::shared_ptr<ssl_socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
||||||
void SendResponse (std::shared_ptr<ssl_socket> socket,
|
void SendResponse (std::shared_ptr<ssl_socket> socket,
|
||||||
std::shared_ptr<I2PControlBuffer> buf, std::ostringstream& response, bool isHtml);
|
std::shared_ptr<I2PControlBuffer> buf, std::string& response, bool isHtml);
|
||||||
void HandleResponseSent (const boost::system::error_code& ecode, std::size_t bytes_transferred,
|
void HandleResponseSent (const boost::system::error_code& ecode, std::size_t bytes_transferred,
|
||||||
std::shared_ptr<ssl_socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
std::shared_ptr<ssl_socket> socket, std::shared_ptr<I2PControlBuffer> buf);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue