cmCTestCurl.h 1.4 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. #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. bool UploadFile(std::string const& url, std::string const& file,
  16. std::string const& fields, std::string& response);
  17. bool HttpRequest(std::string const& url, std::string const& fields,
  18. std::string& response);
  19. // currently only supports CURLOPT_SSL_VERIFYPEER_OFF
  20. // and CURLOPT_SSL_VERIFYHOST_OFF
  21. void SetCurlOptions(std::vector<std::string> const& args);
  22. void SetHttpHeaders(std::vector<std::string> const& v)
  23. {
  24. this->HttpHeaders = v;
  25. }
  26. void SetUseHttp10On() { this->UseHttp10 = true; }
  27. void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
  28. void SetQuiet(bool b) { this->Quiet = b; }
  29. std::string Escape(std::string const& source);
  30. protected:
  31. void SetProxyType();
  32. bool InitCurl();
  33. private:
  34. cmCTest* CTest;
  35. CURL* Curl;
  36. std::vector<std::string> HttpHeaders;
  37. std::string HTTPProxyAuth;
  38. std::string HTTPProxy;
  39. curl_proxytype HTTPProxyType;
  40. bool VerifyHostOff;
  41. bool VerifyPeerOff;
  42. bool UseHttp10;
  43. bool Quiet;
  44. int TimeOutSeconds;
  45. };
  46. #endif