diff options
author | Brad King <brad.king@kitware.com> | 2015-10-12 14:29:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-10-12 14:29:27 (GMT) |
commit | 889d90de4421d721877d48e44de303db56562af4 (patch) | |
tree | 89fc4c395dad61eeeb4ca7546dcfada9cde54a2c | |
parent | 679a5d2185b15dcd0ff73f7c1c2d7d527c53de53 (diff) | |
parent | 2a6e0b611b5b76faf6c97cbfaf4ea3481732bbe9 (diff) | |
download | CMake-889d90de4421d721877d48e44de303db56562af4.zip CMake-889d90de4421d721877d48e44de303db56562af4.tar.gz CMake-889d90de4421d721877d48e44de303db56562af4.tar.bz2 |
Merge branch 'ctest-submit-content-type' into release
-rw-r--r-- | Source/CTest/cmCTestCurl.cxx | 6 | ||||
-rw-r--r-- | Source/CTest/cmCTestSubmitHandler.cxx | 8 |
2 files changed, 14 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 ) { 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; } |