#include <iostream>
using namespace std;
string url =
"http://www.google.es/";
{
string content;
string errmsg;
cout <<
"Retrieving " <<
url <<
"..." << endl;
url, content, errmsg, 80,
"",
"",
nullptr,
nullptr, &out_headers);
{
cout << " Error: " << errmsg << endl;
return;
}
string typ = out_headers.
has(
"Content-Type") ? out_headers[
"Content-Type"]
: string("???");
cout << "Ok: " << content.size() << " bytes of type: " << typ << endl;
}
{
try
{
return 0;
}
catch (const std::exception& e)
{
return -1;
}
}
ERRORCODE_HTTP http_get(const string &url, std::vector< uint8_t > &out_content, string &out_errormsg, int port=80, const string &auth_user=string(), const string &auth_pass=string(), int *out_http_responsecode=nullptr, mrpt::system::TParameters< string > *extra_headers=nullptr, mrpt::system::TParameters< string > *out_headers=nullptr, int timeout_ms=1000)
Perform an HTTP GET operation (version for retrieving the data as a std::vector<uint8_t>)