summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-09-14 12:56:22 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2016-09-14 12:56:22 (GMT)
commit171ea5d3cf58c40807ad9afaf80c0100993f98cb (patch)
treeb3201edff67663300c62e833039d957fef64ca6e /Source
parentb93623550dceac981aa4cc49f9e892c497aee49a (diff)
parentabeb42f1d9efc113ab16600d354f8ad1dd85281f (diff)
downloadCMake-171ea5d3cf58c40807ad9afaf80c0100993f98cb.zip
CMake-171ea5d3cf58c40807ad9afaf80c0100993f98cb.tar.gz
CMake-171ea5d3cf58c40807ad9afaf80c0100993f98cb.tar.bz2
Merge topic 'file-curl-userpw'
abeb42f1 Help: Add notes for topic 'file-curl-userpw' e5ba1041 file(DOWNLOAD|UPLOAD): Add 'USERPWD' suboption
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index ae7a511..2c226cd 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2481,6 +2481,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string hashMatchMSG;
CM_AUTO_PTR<cmCryptoHash> hash;
bool showProgress = false;
+ std::string userpwd;
while (i != args.end()) {
if (*i == "TIMEOUT") {
@@ -2564,6 +2565,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
return false;
}
hashMatchMSG = algo + " hash";
+ } else if (*i == "USERPWD") {
+ ++i;
+ if (i == args.end()) {
+ this->SetError("DOWNLOAD missing string for USERPWD.");
+ return false;
+ }
+ userpwd = *i;
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
@@ -2703,6 +2711,11 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
check_curl_result(res, "DOWNLOAD cannot set progress data: ");
}
+ if (!userpwd.empty()) {
+ res = ::curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd.c_str());
+ check_curl_result(res, "DOWNLOAD cannot set user password: ");
+ }
+
res = ::curl_easy_perform(curl);
/* always cleanup */
@@ -2783,6 +2796,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
std::string logVar;
std::string statusVar;
bool showProgress = false;
+ std::string userpwd;
while (i != args.end()) {
if (*i == "TIMEOUT") {
@@ -2817,6 +2831,13 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
statusVar = *i;
} else if (*i == "SHOW_PROGRESS") {
showProgress = true;
+ } else if (*i == "USERPWD") {
+ ++i;
+ if (i == args.end()) {
+ this->SetError("UPLOAD missing string for USERPWD.");
+ return false;
+ }
+ userpwd = *i;
} else {
// Do not return error for compatibility reason.
std::string err = "Unexpected argument: ";
@@ -2930,6 +2951,11 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
::curl_easy_setopt(curl, CURLOPT_INFILESIZE, static_cast<long>(file_size));
check_curl_result(res, "UPLOAD cannot set input file size: ");
+ if (!userpwd.empty()) {
+ res = ::curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd.c_str());
+ check_curl_result(res, "UPLOAD cannot set user password: ");
+ }
+
res = ::curl_easy_perform(curl);
/* always cleanup */