Class: CurseClient::Downloader
- Inherits:
-
Object
- Object
- CurseClient::Downloader
- Defined in:
- lib/curse_client/downloader.rb
Defined Under Namespace
Classes: DownloadError
Instance Method Summary collapse
Instance Method Details
#fetch(uri, path, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/curse_client/downloader.rb', line 8 def fetch(uri, path, &block) HTTP.get(uri) do |response| case response when Net::HTTPSuccess save_response(response, path, &block) when Net::HTTPRedirection url = URI.escape(response['location'], "[]^") return fetch(url, path, &block) else response.error! end end rescue Exception => e raise DownloadError, e. end |