Add a download strategy that uses HTTP POST

This commit is contained in:
Adam Vandenberg 2010-06-25 19:13:20 -07:00
parent cdb5b2e0d5
commit 55b683b59a

View File

@ -45,11 +45,16 @@ class CurlDownloadStrategy <AbstractDownloadStrategy
@tarball_path
end
# Private method, can be overridden if needed.
def _fetch
curl @url, '-o', @tarball_path
end
def fetch
ohai "Downloading #{@url}"
unless @tarball_path.exist?
begin
curl @url, '-o', @tarball_path
_fetch
rescue Exception
ignore_interrupts { @tarball_path.unlink if @tarball_path.exist? }
raise
@ -115,6 +120,18 @@ private
end
end
# Download via an HTTP POST.
class CurlPostDownloadStrategy <CurlDownloadStrategy
def initialize url, name, version, specs
super
end
def _fetch
base_url,data = @url.split('?')
curl base_url, '-d', data, '-o', @tarball_path
end
end
# Use this strategy to download but not unzip a file.
# Useful for installing jars.
class NoUnzipCurlDownloadStrategy <CurlDownloadStrategy