summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestCurl.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/cmCTestCurl.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/cmCTestCurl.cxx')
-rw-r--r--Source/CTest/cmCTestCurl.cxx6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index b4c0137..fb6cc00 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -166,6 +166,10 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
curlWriteMemoryCallback);
::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
curlDebugCallback);
+ // Be sure to set Content-Type to satisfy fussy modsecurity rules
+ struct curl_slist *headers = ::curl_slist_append(NULL,
+ "Content-Type: text/xml");
+ ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, headers);
std::vector<char> responseData;
std::vector<char> debugData;
::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
@@ -174,6 +178,8 @@ bool cmCTestCurl::UploadFile(std::string const& local_file,
// Now run off and do what you've been told!
::curl_easy_perform(this->Curl);
::fclose(ftpfile);
+ ::curl_easy_setopt(this->Curl, CURLOPT_HTTPHEADER, NULL);
+ ::curl_slist_free_all(headers);
if ( responseData.size() > 0 )
{