summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestCurl.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CTest/cmCTestCurl.cxx')
-rw-r--r--Source/CTest/cmCTestCurl.cxx25
1 files changed, 24 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 06b5e81..b80ea5a 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -143,9 +143,17 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
curlWriteMemoryCallback);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
- // Be sure to set Content-Type to satisfy fussy modsecurity rules
+ // Set Content-Type to satisfy fussy modsecurity rules.
struct curl_slist* headers =
::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml");
+ // Add any additional headers that the user specified.
+ for (std::vector<std::string>::const_iterator h = this->HttpHeaders.begin();
+ h != this->HttpHeaders.end(); ++h) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ this->Quiet);
+ headers = ::curl_slist_append(headers, h->c_str());
+ }
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
std::vector<char> debugData;
@@ -203,7 +211,22 @@ bool cmCTestCurl::HttpRequest(std::string const& url,
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void*)&debugData);
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
+ // Add headers if any were specified.
+ struct curl_slist* headers = CM_NULLPTR;
+ if (!this->HttpHeaders.empty()) {
+ for (std::vector<std::string>::const_iterator h =
+ this->HttpHeaders.begin();
+ h != this->HttpHeaders.end(); ++h) {
+ cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
+ " Add HTTP Header: \"" << *h << "\"" << std::endl,
+ this->Quiet);
+ headers = ::curl_slist_append(headers, h->c_str());
+ }
+ }
+
+ ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
CURLcode res = ::curl_easy_perform(this->Curl);
+ ::curl_slist_free_all(headers);
if (!responseData.empty()) {
response = std::string(responseData.begin(), responseData.end());