example00.cpp 717 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * \file
  3. * The most simple example.
  4. *
  5. */
  6. #include <curlpp/cURLpp.hpp>
  7. #include <curlpp/Easy.hpp>
  8. #include <curlpp/Options.hpp>
  9. using namespace curlpp::options;
  10. int main(int, char **)
  11. {
  12. try
  13. {
  14. // That's all that is needed to do cleanup of used resources (RAII style).
  15. curlpp::Cleanup myCleanup;
  16. // Our request to be sent.
  17. curlpp::Easy myRequest;
  18. // Set the URL.
  19. myRequest.setOpt<Url>("http://example.com");
  20. // Send request and get a result.
  21. // By default the result goes to standard output.
  22. myRequest.perform();
  23. }
  24. catch(curlpp::RuntimeError & e)
  25. {
  26. std::cout << e.what() << std::endl;
  27. }
  28. catch(curlpp::LogicError & e)
  29. {
  30. std::cout << e.what() << std::endl;
  31. }
  32. return 0;
  33. }