cmCTestCurl.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <string>
  6. #include <vector>
  7. #include <cm3p/curl/curl.h>
  8. class cmCTest;
  9. class cmCTestCurl
  10. {
  11. public:
  12. cmCTestCurl(cmCTest*);
  13. ~cmCTestCurl();
  14. cmCTestCurl(const cmCTestCurl&) = delete;
  15. cmCTestCurl& operator=(const cmCTestCurl&) = delete;
  16. bool UploadFile(std::string const& local_file, std::string const& url,
  17. std::string const& fields, std::string& response);
  18. bool HttpRequest(std::string const& url, std::string const& fields,
  19. std::string& response);
  20. // currently only supports CURLOPT_SSL_VERIFYPEER_OFF
  21. // and CURLOPT_SSL_VERIFYHOST_OFF
  22. void SetCurlOptions(std::vector<std::string> const& args);
  23. void SetHttpHeaders(std::vector<std::string> const& v)
  24. {
  25. this->HttpHeaders = v;
  26. }
  27. void SetUseHttp10On() { this->UseHttp10 = true; }
  28. void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
  29. void SetQuiet(bool b) { this->Quiet = b; }
  30. std::string Escape(std::string const& source);
  31. protected:
  32. void SetProxyType();
  33. bool InitCurl();
  34. private:
  35. cmCTest* CTest;
  36. CURL* Curl;
  37. std::vector<std::string> HttpHeaders;
  38. std::string HTTPProxyAuth;
  39. std::string HTTPProxy;
  40. curl_proxytype HTTPProxyType;
  41. bool VerifyHostOff;
  42. bool VerifyPeerOff;
  43. bool UseHttp10;
  44. bool Quiet;
  45. int TimeOutSeconds;
  46. };