summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-09-19 18:50:47 (GMT)
committerBrad King <brad.king@kitware.com>2011-09-19 21:41:48 (GMT)
commit09817e91f9bb03353c49f3c8aa6cb7ad9789fcc7 (patch)
tree86a5539f1b420953ea2aed16307bfb559c20f91d /Source
parentcfc6e01851b58ba61faecbf085d123294e5a78f4 (diff)
downloadCMake-09817e91f9bb03353c49f3c8aa6cb7ad9789fcc7.zip
CMake-09817e91f9bb03353c49f3c8aa6cb7ad9789fcc7.tar.gz
CMake-09817e91f9bb03353c49f3c8aa6cb7ad9789fcc7.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 3b63906..f933666 100644
--- a/Source/cmFileCommand.cxx
+++ b/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: ");