MRPT  1.9.9
comms_http_client/test.cpp
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
/** \example comms_http_client/test.cpp */
//! [example-http-get]
#include <iostream>
using namespace mrpt;
using namespace mrpt::comms;
using namespace mrpt::comms::net;
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);
if (ret != net::erOk)
{
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;
// cout << content << endl;
}
//! [example-http-get]
int main(int argc, char** argv)
{
try
{
if (argc > 1) url = string(argv[1]);
return 0;
}
catch (const std::exception& e)
{
std::cerr << "MRPT error: " << mrpt::exception_to_str(e) << std::endl;
return -1;
}
}



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020