Thanks, Michael and Aaron!<br><br>I pushed your patch (+ a SetError line) here in CMake 'next' :<br><a href="http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef491f78218e255339278656bf6dc26073fef264">http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef491f78218e255339278656bf6dc26073fef264</a><br>
<br><br><div class="gmail_quote">On Fri, Jun 4, 2010 at 11:38 AM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The following patch does work for me:<br>
<br>
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx<br>
index 5611527..3b18e0b 100644<br>
--- a/Source/cmFileCommand.cxx<br>
+++ b/Source/cmFileCommand.cxx<br>
@@ -2629,6 +2629,14 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string><br>
return false;<br>
}<br>
<br>
+ res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);<br>
+ if (res != CURLE_OK)<br>
+ {<br>
+ std::string errstring = "FILE(DOWNLOAD ) error; cannot set follow-redirect option: ";<br>
+ errstring += ::curl_easy_strerror(res);<br>
+ return false;<br>
+ }<br>
+<br>
if(verboseLog.size())<br>
{<br>
res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);<br>
--<br>
<br>
However, I didn't test it thoroughly, and am not sure whether it would be a good idea to restrict the protocols and number of redirects.<br>
<br>
Michael<br>
<div><div></div><div class="h5"><br>
On 4. Jun, 2010, at 17:08 , <<a href="mailto:aaron.meadows@thomsonreuters.com">aaron.meadows@thomsonreuters.com</a>> <<a href="mailto:aaron.meadows@thomsonreuters.com">aaron.meadows@thomsonreuters.com</a>> wrote:<br>
<br>
> I don't know what options are compiled in for CMake, but it looks like<br>
> this is the libcurl option required to follow redirects:<br>
><br>
><br>
><br>
> CURLOPT_FOLLOWLOCATION<br>
><br>
><br>
><br>
> A parameter set to 1 tells the library to follow any Location: header<br>
> that the server sends as part of an HTTP header.<br>
><br>
><br>
><br>
> This means that the library will re-send the same request on the new<br>
> location and follow new Location: headers all the way until no more such<br>
> headers are returned. CURLOPT_MAXREDIRS can be used to limit the number<br>
> of redirects libcurl will follow.<br>
><br>
><br>
><br>
> Since 7.19.4, libcurl can limit what protocols it will automatically<br>
> follow. The accepted protocols are set with CURLOPT_REDIR_PROTOCOLS and<br>
> it excludes the FILE protocol by default.<br>
><br>
><br>
><br>
> Aaron C. Meadows<br>
><br>
> ________________________________<br>
><br>
> From: <a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a> [mailto:<a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a>] On Behalf<br>
> Of David Cole<br>
> Sent: Friday, June 04, 2010 9:47 AM<br>
> To: Michael Wild<br>
> Cc: CMake List<br>
> Subject: Re: [CMake] file(DOWNLOAD) and HTTP 302 (redirect)<br>
><br>
><br>
><br>
> On Fri, Jun 4, 2010 at 8:03 AM, Michael Wild <<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>> wrote:<br>
><br>
> The log looks like this (I've put a message("log = ${log}") into<br>
> ExternalProject.cmake to get this, since the numeric error code is 0):<br>
><br>
> <snip><br>
> -- downloading...<br>
><br>
> src='<a href="http://downloads.sourceforge.net/project/freefoam/ThirdParty/zlib/z" target="_blank">http://downloads.sourceforge.net/project/freefoam/ThirdParty/zlib/z</a><br>
> lib-1.2.5.tar.gz'<br>
><br>
> dst='/Users/mwild/Projects/FreeFOAM/build-pu/ThirdParty/zlib/src/zlib-1.<br>
> 2.5.tar.gz'<br>
> timeout='none'<br>
> log = About to connect() to <a href="http://downloads.sourceforge.net" target="_blank">downloads.sourceforge.net</a> port 80 (#0)<br>
> Trying 216.34.181.59... connected<br>
> Connected to <a href="http://downloads.sourceforge.net" target="_blank">downloads.sourceforge.net</a> (216.34.181.59) port 80 (#0)<br>
> GET /project/freefoam/ThirdParty/zlib/zlib-1.2.5.tar.gz HTTP/1.1<br>
> Host: <a href="http://downloads.sourceforge.net" target="_blank">downloads.sourceforge.net</a><br>
> Accept: */*<br>
><br>
> HTTP/1.1 302 Found<br>
> X-Powered-By: PHP/5.2.9<br>
> Content-Disposition: attachment; filename="zlib-1.2.5.tar.gz"<br>
> Location:<br>
> <a href="http://surfnet.dl.sourceforge.net/project/freefoam/ThirdParty/zlib/zlib-" target="_blank">http://surfnet.dl.sourceforge.net/project/freefoam/ThirdParty/zlib/zlib-</a><br>
> 1.2.5.tar.gz<br>
> Content-type<br>
> <<a href="http://surfnet.dl.sourceforge.net/project/freefoam/ThirdParty/zlib/zlib" target="_blank">http://surfnet.dl.sourceforge.net/project/freefoam/ThirdParty/zlib/zlib</a><br>
</div></div>> -1.2.5.tar.gz%0d%0aContent-type> : text/html<br>
<div><div></div><div class="h5">> Content-Length: 0<br>
> Date: Fri, 04 Jun 2010 07:52:13 GMT<br>
> Server: lighttpd/1.4.26<br>
><br>
> Connection #0 to host <a href="http://downloads.sourceforge.net" target="_blank">downloads.sourceforge.net</a> left intact<br>
> Closing connection #0<br>
><br>
> -- downloading... done<br>
> </snip><br>
><br>
> So you see, CMake really thinks this succeeded.<br>
><br>
><br>
><br>
> Hmm. I wonder if there's some sort of curl option we should be passing<br>
> to get redirects to work automatically...?<br>
><br>
><br>
><br>
><br>
> I really am looking forward to the EXPECTED_MD5 feature, please<br>
> also make it available through ExternalProject_Add! Currently I'm doing<br>
> this manually via an additional step, but it's awfully fragile...<br>
><br>
><br>
><br>
> It is. That was actually the main motivation for the additional<br>
> file(DOWNLOAD arg... In CMake 'next' there's a URL_MD5 arg to<br>
> ExternalProject_Add now.<br>
><br>
><br>
><br>
><br>
><br>
><br>
> Michael<br>
><br>
><br>
> On 4. Jun, 2010, at 13:57 , David Cole wrote:<br>
><br>
> > I'm pretty sure the original intent was for file(DOWNLOAD ...)<br>
> to not raise<br>
> > errors so that scripts can analyze status and log and decide<br>
> what to do next<br>
> > rather than forcing a CMake error...<br>
> ><br>
> > I recently added EXPECTED_MD5 to file(DOWNLOAD in the 'next'<br>
> branch of<br>
> > CMake. If a download fails when there's an expected MD5 sum<br>
> given, then it<br>
> > *does* raise an error. Perhaps you'll find that useful in the<br>
> next<br>
> > release...<br>
> ><br>
> > Cheers,<br>
> > David C.<br>
> ><br>
> ><br>
> > On Fri, Jun 4, 2010 at 7:55 AM, David Cole<br>
> <<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>> wrote:<br>
> ><br>
> >> What if you do something this...? What do status and log tell<br>
> you?<br>
> >><br>
> >> set(remote "http://......")<br>
> >> set(local "some file name")<br>
> >><br>
> >> file(DOWNLOAD<br>
> >><br>
> >> "${remote}"<br>
> >><br>
> >> "${local}"<br>
> >><br>
> >> STATUS status<br>
> >><br>
> >> LOG log)<br>
> >><br>
> >><br>
> >> list(GET status 0 status_code)<br>
> >><br>
> >> list(GET status 1 status_string)<br>
> >><br>
> >><br>
> >> if(NOT status_code EQUAL 0)<br>
> >><br>
> >> message(FATAL_ERROR "error: downloading '${remote}' failed<br>
> >><br>
> >> status_code: ${status_code}<br>
> >><br>
> >> status_string: ${status_string}<br>
> >><br>
> >> log: ${log}<br>
> >><br>
> >> ")<br>
> >><br>
> >> endif()<br>
> >><br>
> >><br>
> >><br>
> >> On Fri, Jun 4, 2010 at 4:00 AM, Michael Wild<br>
> <<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>> wrote:<br>
> >><br>
> >>> When downloading something from<br>
</div></div>> <a href="http://downloads.sourceforge.net/" target="_blank">http://downloads.sourceforge.net/</a>. <<a href="http://downloads.sourceforge.net/" target="_blank">http://downloads.sourceforge.net/</a>><br>
<div><div></div><div class="h5">> .. you<br>
> >>> always get a 302 redirect to one of the many mirror servers.<br>
> Unfortunately,<br>
> >>> it seems that file(DOWNLOAD ...) doesn't follow the<br>
> redirect, but just stops<br>
> >>> and leaves an empty file behind. No error, no nothing. Is<br>
> this intentional?<br>
> >>><br>
> >>> I'd rather not use a specific mirror...<br>
> >>><br>
> >>> Michael<br>
> >>> _______________________________________________<br>
> >>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> >>><br>
> >>> Visit other Kitware open-source projects at<br>
> >>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> >>><br>
> >>> Please keep messages on-topic and check the CMake FAQ at:<br>
> >>> <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
> >>><br>
> >>> Follow this link to subscribe/unsubscribe:<br>
> >>> <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
> >>><br>
> >><br>
> >><br>
><br>
><br>
><br>
><br>
><br>
> This email was sent to you by Thomson Reuters, the global news and information company.<br>
> Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.<br>
><br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
<br>
</div></div></blockquote></div><br>