cmake/Source/CTest/cmCTestCurl.h

60 lines
1.5 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2015-04-27 22:25:09 +02:00
2016-10-30 18:24:19 +01:00
#include <string>
#include <vector>
2015-04-27 22:25:09 +02:00
2024-07-09 14:46:46 +02:00
#include <cm/optional>
2020-08-30 11:54:41 +02:00
#include <cm3p/curl/curl.h>
2020-02-01 23:06:01 +01:00
2015-04-27 22:25:09 +02:00
class cmCTest;
2024-07-09 14:46:46 +02:00
struct cmCTestCurlOpts
{
cmCTestCurlOpts(cmCTest* ctest);
cm::optional<int> TLSVersionOpt;
cm::optional<bool> TLSVerifyOpt;
bool VerifyHostOff = false;
};
2015-04-27 22:25:09 +02:00
class cmCTestCurl
{
public:
cmCTestCurl(cmCTest*);
~cmCTestCurl();
2019-11-11 23:01:05 +01:00
cmCTestCurl(const cmCTestCurl&) = delete;
cmCTestCurl& operator=(const cmCTestCurl&) = delete;
2018-08-09 18:06:22 +02:00
bool UploadFile(std::string const& local_file, std::string const& url,
2016-07-09 11:21:54 +02:00
std::string const& fields, std::string& response);
bool HttpRequest(std::string const& url, std::string const& fields,
2015-04-27 22:25:09 +02:00
std::string& response);
2017-07-20 19:35:53 +02:00
void SetHttpHeaders(std::vector<std::string> const& v)
{
this->HttpHeaders = v;
}
2016-07-09 11:21:54 +02:00
void SetUseHttp10On() { this->UseHttp10 = true; }
void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
2017-04-14 19:02:05 +02:00
void SetQuiet(bool b) { this->Quiet = b; }
2015-04-27 22:25:09 +02:00
std::string Escape(std::string const& source);
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
protected:
void SetProxyType();
bool InitCurl();
2016-07-09 11:21:54 +02:00
2015-04-27 22:25:09 +02:00
private:
cmCTest* CTest;
2024-07-09 14:46:46 +02:00
cmCTestCurlOpts CurlOpts;
CURL* Curl = nullptr;
2017-07-20 19:35:53 +02:00
std::vector<std::string> HttpHeaders;
2015-04-27 22:25:09 +02:00
std::string HTTPProxyAuth;
std::string HTTPProxy;
curl_proxytype HTTPProxyType;
2024-07-09 14:46:46 +02:00
bool UseHttp10 = false;
bool Quiet = false;
int TimeOutSeconds = 0;
2015-04-27 22:25:09 +02:00
};