[Cmake-commits] CMake branch, next, updated. v3.6.2-2090-ge53d142

Brad King brad.king at kitware.com
Thu Sep 15 14:46:40 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  e53d142f05e8d4659638ffa513addeecdb4f154b (commit)
       via  8f6cb36695df3ded9e242c35c4b0e79850d24a31 (commit)
      from  9db24a8ccd641c94574302d78b9e5b4fdaa84ee5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e53d142f05e8d4659638ffa513addeecdb4f154b
commit e53d142f05e8d4659638ffa513addeecdb4f154b
Merge: 9db24a8 8f6cb36
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Thu Sep 15 14:46:38 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Thu Sep 15 14:46:38 2016 -0400

    Merge topic 'file-curl-httpheader' into next
    
    8f6cb366 file(DOWNLOAD|UPLOAD): Add HTTPHEADER suboption


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f6cb36695df3ded9e242c35c4b0e79850d24a31
commit 8f6cb36695df3ded9e242c35c4b0e79850d24a31
Author:     Ruslan Baratov <ruslan_baratov at yahoo.com>
AuthorDate: Thu Sep 15 08:38:12 2016 +0300
Commit:     Ruslan Baratov <ruslan_baratov at yahoo.com>
CommitDate: Thu Sep 15 21:41:39 2016 +0300

    file(DOWNLOAD|UPLOAD): Add HTTPHEADER suboption

diff --git a/Help/command/file.rst b/Help/command/file.rst
index f8727f0..77e9f62 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -225,6 +225,9 @@ Options to both ``DOWNLOAD`` and ``UPLOAD`` are:
 ``USERPWD <username>:<password>``
   Set username and password for operation.
 
+``HTTPHEADER <HTTP-header>``
+  HTTP header for operation. Suboption can be repeated several times.
+
 Additional options to ``DOWNLOAD`` are:
 
 ``EXPECTED_HASH ALGO=<value>``
diff --git a/Help/release/dev/file-curl-httpheader.rst b/Help/release/dev/file-curl-httpheader.rst
new file mode 100644
index 0000000..2147d40
--- /dev/null
+++ b/Help/release/dev/file-curl-httpheader.rst
@@ -0,0 +1,5 @@
+file-curl-httpheader
+--------------------
+
+* The :command:`file(DOWNLOAD)` and :command:`file(UPLOAD)` commands
+  gained a ``HTTPHEADER <HTTP-header>`` option.
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);
diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt
new file mode 100644
index 0000000..247923b
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at DOWNLOAD-httpheader-not-set.cmake:[0-9]+ \(file\):
+  file DOWNLOAD missing string for HTTPHEADER.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake
new file mode 100644
index 0000000..6efc958
--- /dev/null
+++ b/Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake
@@ -0,0 +1 @@
+file(DOWNLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER)
diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake
index d8e9ce0..5d560c0 100644
--- a/Tests/RunCMake/file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file/RunCMakeTest.cmake
@@ -2,8 +2,10 @@ include(RunCMake)
 
 run_cmake(DOWNLOAD-hash-mismatch)
 run_cmake(DOWNLOAD-unused-argument)
+run_cmake(DOWNLOAD-httpheader-not-set)
 run_cmake(DOWNLOAD-pass-not-set)
 run_cmake(UPLOAD-unused-argument)
+run_cmake(UPLOAD-httpheader-not-set)
 run_cmake(UPLOAD-pass-not-set)
 run_cmake(INSTALL-DIRECTORY)
 run_cmake(INSTALL-MESSAGE-bad)
diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt
new file mode 100644
index 0000000..341baf5
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at UPLOAD-httpheader-not-set.cmake:[0-9]+ \(file\):
+  file UPLOAD missing string for HTTPHEADER.
+Call Stack \(most recent call first\):
+  CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake
new file mode 100644
index 0000000..18d43cc
--- /dev/null
+++ b/Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake
@@ -0,0 +1 @@
+file(UPLOAD "" "" HTTPHEADER "Content-Type: application/x-compressed-tar" HTTPHEADER)

-----------------------------------------------------------------------

Summary of changes:
 Help/command/file.rst                              |    3 ++
 Help/release/dev/file-curl-httpheader.rst          |    5 +++
 Source/cmFileCommand.cxx                           |   36 ++++++++++++++++++++
 .../DOWNLOAD-httpheader-not-set-result.txt}        |    0
 .../file/DOWNLOAD-httpheader-not-set-stderr.txt    |    4 +++
 .../file/DOWNLOAD-httpheader-not-set.cmake         |    1 +
 Tests/RunCMake/file/RunCMakeTest.cmake             |    2 ++
 .../UPLOAD-httpheader-not-set-result.txt}          |    0
 .../file/UPLOAD-httpheader-not-set-stderr.txt      |    4 +++
 .../RunCMake/file/UPLOAD-httpheader-not-set.cmake  |    1 +
 10 files changed, 56 insertions(+)
 create mode 100644 Help/release/dev/file-curl-httpheader.rst
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => file/DOWNLOAD-httpheader-not-set-result.txt} (100%)
 create mode 100644 Tests/RunCMake/file/DOWNLOAD-httpheader-not-set-stderr.txt
 create mode 100644 Tests/RunCMake/file/DOWNLOAD-httpheader-not-set.cmake
 copy Tests/RunCMake/{Android/BadSYSROOT-result.txt => file/UPLOAD-httpheader-not-set-result.txt} (100%)
 create mode 100644 Tests/RunCMake/file/UPLOAD-httpheader-not-set-stderr.txt
 create mode 100644 Tests/RunCMake/file/UPLOAD-httpheader-not-set.cmake


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list