mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Add a download strategy that uses HTTP POST
This commit is contained in:
parent
cdb5b2e0d5
commit
55b683b59a
@ -45,11 +45,16 @@ class CurlDownloadStrategy <AbstractDownloadStrategy
|
|||||||
@tarball_path
|
@tarball_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Private method, can be overridden if needed.
|
||||||
|
def _fetch
|
||||||
|
curl @url, '-o', @tarball_path
|
||||||
|
end
|
||||||
|
|
||||||
def fetch
|
def fetch
|
||||||
ohai "Downloading #{@url}"
|
ohai "Downloading #{@url}"
|
||||||
unless @tarball_path.exist?
|
unless @tarball_path.exist?
|
||||||
begin
|
begin
|
||||||
curl @url, '-o', @tarball_path
|
_fetch
|
||||||
rescue Exception
|
rescue Exception
|
||||||
ignore_interrupts { @tarball_path.unlink if @tarball_path.exist? }
|
ignore_interrupts { @tarball_path.unlink if @tarball_path.exist? }
|
||||||
raise
|
raise
|
||||||
@ -115,6 +120,18 @@ private
|
|||||||
end
|
end
|
||||||
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.
|
# Use this strategy to download but not unzip a file.
|
||||||
# Useful for installing jars.
|
# Useful for installing jars.
|
||||||
class NoUnzipCurlDownloadStrategy <CurlDownloadStrategy
|
class NoUnzipCurlDownloadStrategy <CurlDownloadStrategy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user