浏览代码

Make file(DOWNLOAD) fail on http error

If a http server responds with a result code greater than 400 then the
data returned from the download probably do not match that expected.
Teach file(DOWNLOAD) to fail with an error in this case instead of
silently pretending that the download worked.  The file(UPLOAD) command
already does this.
Brad King 14 年之前
父节点
当前提交
09817e91f9
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Source/cmFileCommand.cxx

+ 4 - 0
Source/cmFileCommand.cxx

@@ -2753,6 +2753,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
   ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
   check_curl_result(res, "DOWNLOAD cannot set url: ");
 
+  // enable HTTP ERROR parsing
+  res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1);
+  check_curl_result(res, "DOWNLOAD cannot set http failure option: ");
+
   res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
                            cmWriteToFileCallback);
   check_curl_result(res, "DOWNLOAD cannot set write function: ");