Use http.rb to ensure timeout enforcement for cache purging, disable crashing flag for now

This commit is contained in:
Kyle Drake 2016-10-23 12:52:44 -05:00
parent c3ea1fc9e4
commit 80b3f6b0be
3 changed files with 11 additions and 16 deletions

View file

@ -22,17 +22,14 @@ class PurgeCacheWorker
retry_encoded = false
begin
RestClient::Request.execute method: :head, url: url, timeout: HTTP_TIMEOUT, headers: {
host: URI::encode("#{username}.neocities.org"),
cache_purge: '1'
}
HTTP.timeout(read: 10, write: 10, connect: 2).
headers(host: URI::encode("#{username}.neocities.org"), cache_purge: '1').
head(url)
rescue URI::InvalidURIError
raise if retry_encoded == true
url = URI.encode url
retry_encoded = true
retry
rescue RestClient::ResourceNotFound
rescue RestClient::Forbidden
end
end
end