Get number response / ping bits working.

This commit is contained in:
Michael Meeks 2017-02-16 11:24:07 +00:00 committed by Jan Holesovsky
parent 7a225dcbb3
commit a06fb365cb
2 changed files with 5 additions and 5 deletions

View file

@ -91,6 +91,7 @@ struct Session
std::string result(std::istreambuf_iterator<char>(responseStream), {});
std::cerr << "Got response '" << result << "'\n";
number = std::stoi(result);
}
catch (const Poco::Exception &e)
{
@ -118,7 +119,7 @@ public:
assert (back == count + 1);
back = second.getResponse();
assert (back == count + 1);
assert (back == count + 2);
return 0;
}

View file

@ -58,20 +58,19 @@ public:
// complex algorithmic core:
number = number + 1;
std::string numberString = std::to_string(number);
std::ostringstream oss;
oss << "HTTP/1.1 200 OK\r\n"
<< "Date: Once, Upon a time GMT\r\n" // Mon, 27 Jul 2009 12:28:53 GMT
<< "Server: madeup string (Linux)\r\n"
<< "Content-Length: " << _inBuffer.size() << "\r\n"
<< "Content-Length: " << numberString.size() << "\r\n"
<< "Content-Type: text/plain\r\n"
<< "Connection: Closed\r\n"
<< "\r\n"
<< numberString;
;
std::string str = oss.str();
_outBuffer.insert(_outBuffer.end(), str.begin(), str.end());
// append the content we got:
_outBuffer.insert(_outBuffer.end(), _inBuffer.begin(), _inBuffer.end());
_inBuffer.clear();
}
};