cURL / Mailing Lists / curl-users / Single Mail

curl-users

Patch for Metalink Support

From: Tatsuhiro Tsujikawa <tatsuhiro.t_at_gmail.com>
Date: Sat, 13 Dec 2008 00:31:29 +0900

Hi,

I made a patch to add very basic Metalink support to curl command-line
tool. The patch is made against curl-7.19.2. Although the patch is still
rather experimental, it provides basic fail over functionality.

Libmetalink library is used to parse Metalink XML file. I added
configure option for it in configure.ac.
Libmetalink is hosted at https://launchpad.net/libmetalink and there are
ubuntu package: https://launchpad.net/~bneijt/+archive

I added --metalink option which takes Metalink XML filename. If it is
given, curl parses the file and retrieves available URI.
If a problem occurs in a URL, curl tries next URL. In other words, it
currently supports fail over functionality.
I'm also planing to add checksum validation function.

While testing some metalinks, I found that I have to pass at least 2
arguments other than --metalink to get it work with Metalink: -C -, -f.
"-C -" is needed to continue the failed download. "-f" is needed to
avoid the curl to exit when it encounters error like 404(hmm, maybe -f
option can be omitted with further hacks).

For storing multiple URLs, I added alternate_url to struct getout.
alternate_url is a pointer to the array of URLs. In metalink download,
alternate_url is used instead of url member.
In order to use next URL when current URL is failed, I hacked 2nd URL
globing loop to iterate alternate_url. Because I thought Metalink file
really contains URLs need to be globed, I turned off URL globing in this
loop, but it may look a little bit ugly. Is there any good place to
iterate URLs for fail over?

Best regards,

Tatsuhiro Tsujikawa

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2008-12-12