summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestSubmitHandler.cxx
diff options
context:
space:
mode:
authorDerek Bruening <bruening@google.com>2015-10-07 21:51:26 (GMT)
committerBrad King <brad.king@kitware.com>2015-10-12 14:17:04 (GMT)
commit2a6e0b611b5b76faf6c97cbfaf4ea3481732bbe9 (patch)
tree011dc6694741a4f47ac2309d6971152a08bf4861 /Source/CTest/cmCTestSubmitHandler.cxx
parent3187de20fd9949ab90df4651f5d1ae0d218a9afd (diff)
downloadCMake-2a6e0b611b5b76faf6c97cbfaf4ea3481732bbe9.zip
CMake-2a6e0b611b5b76faf6c97cbfaf4ea3481732bbe9.tar.gz
CMake-2a6e0b611b5b76faf6c97cbfaf4ea3481732bbe9.tar.bz2
CTest: Set Content-Type header for http file upload (#15774)
Sets the Content-Type header for http file uploads to avoid running afoul of ModSecurity rules on the server.
Diffstat (limited to 'Source/CTest/cmCTestSubmitHandler.cxx')
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 1e12f15..833cad6 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -338,6 +338,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
CURLcode res;
FILE* ftpfile;
char error_buffer[1024];
+ struct curl_slist *headers = ::curl_slist_append(NULL,
+ "Content-Type: text/xml");
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
@@ -420,6 +422,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+ // Be sure to set Content-Type to satisfy fussy modsecurity rules
+ ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+
std::string local_file = *file;
if ( !cmSystemTools::FileExists(local_file.c_str()) )
{
@@ -477,6 +482,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
<< local_file << std::endl);
::curl_easy_cleanup(curl);
+ ::curl_slist_free_all(headers);
::curl_global_cleanup();
return false;
}
@@ -621,6 +627,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
<< std::endl);
}
::curl_easy_cleanup(curl);
+ ::curl_slist_free_all(headers);
::curl_global_cleanup();
return false;
}
@@ -630,6 +637,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
" Uploaded: " + local_file << std::endl, this->Quiet);
}
}
+ ::curl_slist_free_all(headers);
::curl_global_cleanup();
return true;
}