MRPT  1.9.9
comms_http_client/test.cpp
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| http://www.mrpt.org/ |
| |
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
| See: http://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See details in http://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]
// ------------------------------------------------------
// MAIN
// ------------------------------------------------------
int main(int argc, char** argv)
{
try
{
if (argc > 1) url = string(argv[1]);
return 0;
}
catch (std::exception& e)
{
std::cout << "Exception: " << e.what() << std::endl;
return -1;
}
catch (...)
{
printf("Untyped exception!");
return -1;
}
}



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020