|
|
@@ -43,7 +43,6 @@
|
|
|
#include "cmCTestTestHandler.h"
|
|
|
#include "cmCTestUpdateHandler.h"
|
|
|
#include "cmCTestUploadHandler.h"
|
|
|
-#include "cmCurl.h"
|
|
|
#include "cmDynamicLoader.h"
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
@@ -302,88 +301,6 @@ std::string cmCTest::GetCostDataFile()
|
|
|
return fname;
|
|
|
}
|
|
|
|
|
|
-#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
-static size_t HTTPResponseCallback(void* ptr, size_t size, size_t nmemb,
|
|
|
- void* data)
|
|
|
-{
|
|
|
- int realsize = static_cast<int>(size * nmemb);
|
|
|
-
|
|
|
- std::string* response = static_cast<std::string*>(data);
|
|
|
- const char* chPtr = static_cast<char*>(ptr);
|
|
|
- *response += chPtr;
|
|
|
-
|
|
|
- return realsize;
|
|
|
-}
|
|
|
-
|
|
|
-int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
|
|
|
- std::string& response, std::string const& fields,
|
|
|
- std::string const& putFile, int timeout)
|
|
|
-{
|
|
|
- CURL* curl;
|
|
|
- FILE* file;
|
|
|
- ::curl_global_init(CURL_GLOBAL_ALL);
|
|
|
- curl = ::curl_easy_init();
|
|
|
- cmCurlSetCAInfo(curl);
|
|
|
-
|
|
|
- // set request options based on method
|
|
|
- switch (method) {
|
|
|
- case cmCTest::HTTP_POST:
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_POST, 1);
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_POSTFIELDS, fields.c_str());
|
|
|
- break;
|
|
|
- case cmCTest::HTTP_PUT:
|
|
|
- if (!cmSystemTools::FileExists(putFile)) {
|
|
|
- response = "Error: File ";
|
|
|
- response += putFile + " does not exist.\n";
|
|
|
- return -1;
|
|
|
- }
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_PUT, 1);
|
|
|
- file = cmsys::SystemTools::Fopen(putFile, "rb");
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_INFILE, file);
|
|
|
- // fall through to append GET fields
|
|
|
- CM_FALLTHROUGH;
|
|
|
- case cmCTest::HTTP_GET:
|
|
|
- if (!fields.empty()) {
|
|
|
- url += "?" + fields;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
-
|
|
|
- // set response options
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HTTPResponseCallback);
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_FILE, &response);
|
|
|
- ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
|
|
|
-
|
|
|
- CURLcode res = ::curl_easy_perform(curl);
|
|
|
-
|
|
|
- ::curl_easy_cleanup(curl);
|
|
|
- ::curl_global_cleanup();
|
|
|
-
|
|
|
- return static_cast<int>(res);
|
|
|
-}
|
|
|
-#endif
|
|
|
-
|
|
|
-std::string cmCTest::MakeURLSafe(const std::string& str)
|
|
|
-{
|
|
|
- std::ostringstream ost;
|
|
|
- char buffer[10];
|
|
|
- for (unsigned char ch : str) {
|
|
|
- if ((ch > 126 || ch < 32 || ch == '&' || ch == '%' || ch == '+' ||
|
|
|
- ch == '=' || ch == '@') &&
|
|
|
- ch != 9) {
|
|
|
- sprintf(buffer, "%02x;", static_cast<unsigned int>(ch));
|
|
|
- ost << buffer;
|
|
|
- } else {
|
|
|
- ost << ch;
|
|
|
- }
|
|
|
- }
|
|
|
- return ost.str();
|
|
|
-}
|
|
|
-
|
|
|
std::string cmCTest::DecodeURL(const std::string& in)
|
|
|
{
|
|
|
std::string out;
|