Files
danbooru/app/logical/downloads/rewrite_strategies/base.rb
evazion c0a803e3a6 Allow ugoira to be uploaded directly from the zip URL.
This refactors things such that

* Fetching the ugoira frame data happens at the end of rewrite, not
  rewrite_html_pages. This way uploading zip URLs should work.
* The source data is cached in an instance variable in case it
  was indeed fetched during rewrite_html_pages. This way it doesn't get
  fetched a second time.
2014-10-19 02:30:03 -07:00

32 lines
690 B
Ruby

module Downloads
module RewriteStrategies
class Base
def initialize(url = nil)
@url = url
end
def self.strategies
[Pixiv, NicoSeiga, Twitpic, DeviantArt, Tumblr, Moebooru]
end
def rewrite(url, headers, data = {})
return [url, headers, data]
end
protected
def http_exists?(url, headers)
exists = false
uri = URI.parse(url)
Net::HTTP.start(uri.host, uri.port) do |http|
http.request_head(uri.request_uri, headers) do |res|
if res.is_a?(Net::HTTPSuccess)
exists = true
end
end
end
exists
end
end
end
end