aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/quiet_opener.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb
index 11adfe402..2f78f76ad 100644
--- a/lib/quiet_opener.rb
+++ b/lib/quiet_opener.rb
@@ -15,12 +15,14 @@ def quietly_try_to_purge(host, url)
begin
result = ""
result_body = ""
- Net::HTTP.start(host) {|http|
- request = Net::HTTP::Purge.new(url)
- response = http.request(request)
- result = response.code
- result_body = response.body
- }
+ Net::HTTP.bind '127.0.0.1' do
+ Net::HTTP.start(host) {|http|
+ request = Net::HTTP::Purge.new(url)
+ response = http.request(request)
+ result = response.code
+ result_body = response.body
+ }
+ end
rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH
Rails.logger.warn("Unable to reach host #{host}")
end