|
@@ -143,9 +143,17 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
|
|
|
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
|
|
::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
|
|
|
curlWriteMemoryCallback);
|
|
curlWriteMemoryCallback);
|
|
|
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION, curlDebugCallback);
|
|
::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 =
|
|
struct curl_slist* headers =
|
|
|
::curl_slist_append(CM_NULLPTR, "Content-Type: text/xml");
|
|
::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);
|
|
::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
|
|
|
std::vector<char> responseData;
|
|
std::vector<char> responseData;
|
|
|
std::vector<char> debugData;
|
|
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_DEBUGDATA, (void*)&debugData);
|
|
|
::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
|
|
::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);
|
|
CURLcode res = ::curl_easy_perform(this->Curl);
|
|
|
|
|
+ ::curl_slist_free_all(headers);
|
|
|
|
|
|
|
|
if (!responseData.empty()) {
|
|
if (!responseData.empty()) {
|
|
|
response = std::string(responseData.begin(), responseData.end());
|
|
response = std::string(responseData.begin(), responseData.end());
|