cmCTestCurl.h 1.5 KB

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