Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CTest/cmCTestCurl.h
5000 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <string>
8
#include <vector>
9
10
#include <cm/optional>
11
12
#include <cm3p/curl/curl.h>
13
14
class cmCTest;
15
16
struct cmCTestCurlOpts
17
{
18
cmCTestCurlOpts(cmCTest* ctest);
19
cm::optional<int> TLSVersionOpt;
20
cm::optional<bool> TLSVerifyOpt;
21
bool VerifyHostOff = false;
22
};
23
24
class cmCTestCurl
25
{
26
public:
27
cmCTestCurl(cmCTest*);
28
~cmCTestCurl();
29
cmCTestCurl(cmCTestCurl const&) = delete;
30
cmCTestCurl& operator=(cmCTestCurl const&) = delete;
31
bool UploadFile(std::string const& local_file, std::string const& url,
32
std::string const& fields, std::string& response);
33
bool HttpRequest(std::string const& url, std::string const& fields,
34
std::string& response);
35
void SetHttpHeaders(std::vector<std::string> const& v)
36
{
37
this->HttpHeaders = v;
38
}
39
void SetUseHttp10On() { this->UseHttp10 = true; }
40
void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s; }
41
void SetQuiet(bool b) { this->Quiet = b; }
42
std::string Escape(std::string const& source);
43
44
protected:
45
void SetProxyType();
46
bool InitCurl();
47
48
private:
49
cmCTest* CTest;
50
cmCTestCurlOpts CurlOpts;
51
CURL* Curl = nullptr;
52
std::vector<std::string> HttpHeaders;
53
std::string HTTPProxyAuth;
54
std::string HTTPProxy;
55
long HTTPProxyType;
56
bool UseHttp10 = false;
57
bool Quiet = false;
58
int TimeOutSeconds = 0;
59
};
60
61