summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-16 14:21:23 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-16 14:21:23 (GMT)
commit4356bd7fe382585e59033287dcc43386689e5dc2 (patch)
treeacb976577f944b42f4db46675f17625f6368a5a6 /Source
parent38a378e10d93740c11ac713c6035e26d6838ad96 (diff)
parent8f6cb36695df3ded9e242c35c4b0e79850d24a31 (diff)
downloadCMake-4356bd7fe382585e59033287dcc43386689e5dc2.zip
CMake-4356bd7fe382585e59033287dcc43386689e5dc2.tar.gz
CMake-4356bd7fe382585e59033287dcc43386689e5dc2.tar.bz2
Merge topic 'file-curl-httpheader'
8f6cb366 file(DOWNLOAD|UPLOAD): Add HTTPHEADER suboption
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 2c226cd..c10f426 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2483,6 +2483,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
bool showProgress = false;
std::string userpwd;
+ std::list<std::string> curl_headers;
+
while (i != args.end()) {
if (*i == "TIMEOUT") {
++i;
@@ -2572,6 +2574,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
return false;
}
userpwd = *i;
+ } else if (*i == "HTTPHEADER") {
+ ++i;
+ if (i == args.end()) {
+ this->SetError("DOWNLOAD missing string for HTTPHEADER.");
+ return false;
+ }
+ curl_headers.push_back(*i);
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
@@ -2716,8 +2725,17 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
check_curl_result(res, "DOWNLOAD cannot set user password: ");
}
+ struct curl_slist* headers = CM_NULLPTR;
+ for (std::list<std::string>::const_iterator h = curl_headers.begin();
+ h != curl_headers.end(); ++h) {
+ headers = ::curl_slist_append(headers, h->c_str());
+ }
+ ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+
res = ::curl_easy_perform(curl);
+ ::curl_slist_free_all(headers);
+
/* always cleanup */
g_curl.release();
::curl_easy_cleanup(curl);
@@ -2798,6 +2816,8 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
bool showProgress = false;
std::string userpwd;
+ std::list<std::string> curl_headers;
+
while (i != args.end()) {
if (*i == "TIMEOUT") {
++i;
@@ -2838,6 +2858,13 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
return false;
}
userpwd = *i;
+ } else if (*i == "HTTPHEADER") {
+ ++i;
+ if (i == args.end()) {
+ this->SetError("UPLOAD missing string for HTTPHEADER.");
+ return false;
+ }
+ curl_headers.push_back(*i);
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
@@ -2956,8 +2983,17 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
check_curl_result(res, "UPLOAD cannot set user password: ");
}
+ struct curl_slist* headers = CM_NULLPTR;
+ for (std::list<std::string>::const_iterator h = curl_headers.begin();
+ h != curl_headers.end(); ++h) {
+ headers = ::curl_slist_append(headers, h->c_str());
+ }
+ ::curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
+
res = ::curl_easy_perform(curl);
+ ::curl_slist_free_all(headers);
+
/* always cleanup */
g_curl.release();
::curl_easy_cleanup(curl);