I am using Poco to send HTTP requests, as the name implies. Right now, I'm just trying to send a GET request to google.com and store the resulting HTML in a string to test out Poco and see if it fits what I need. However, I'm having a little trouble with this. Here's my code:
try
{
Poco::URI uri("https://www.google.com");
std::string path(uri.getPathAndQuery());
if (path.empty()) path = "/";
Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, path, Poco::Net::HTTPMessage::HTTP_1_1);
request.add("Content-Length", "0");
Poco::Net::HTTPResponse response;
doRequest(session, request, response);
}
catch (Poco::Exception& exc)
{
OutputDebugStringA(exc.displayText().c_str());
}
void doRequest(Poco::Net::HTTPSClientSession& session, Poco::Net::HTTPRequest& request, Poco::Net::HTTPResponse& response)
{
session.sendRequest(request);
std::istream& is = session.receiveResponse(response);
std::string body(std::istreambuf_iterator<char>(is), { });
message = (LPCWSTR)response.getStatus();
}
I have put breakpoints on every line of doRequest, but the only ones that are triggered are the first two. After clicking continue on the second, the program simply continues as normal. I'm not getting any exceptions or anything. I am adding Content-Length: 0
to avoid a NoMessageException from Poco.