switch to httparty

This commit is contained in:
r888888888
2017-06-29 17:10:07 -07:00
parent ed7b80c016
commit eb6c5e3af5
16 changed files with 108 additions and 182 deletions

View File

@@ -27,15 +27,12 @@ class PopularSearchService
dates = date.strftime("%Y-%m-%d")
Cache.get("ps-#{scale}-#{dates}", 1.minute) do
url = URI.parse("#{Danbooru.config.reportbooru_server}/hits/#{scale}?date=#{dates}")
response = ""
Net::HTTP.start(url.host, url.port, :use_ssl => url.is_a?(URI::HTTPS)) do |http|
http.read_timeout = 1
http.request_get(url.request_uri) do |res|
if res.is_a?(Net::HTTPSuccess)
response = res.body
end
end
url = "#{Danbooru.config.reportbooru_server}/hits/#{scale}?date=#{dates}"
response = HTTParty.get(url, timeout: 3)
if response.success?
response = response.body
else
response = ""
end
response
end.to_s.force_encoding("utf-8")