aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-04-17 12:55:18 +0100
committerLouise Crow <louise.crow@gmail.com>2013-04-17 12:55:18 +0100
commita47237d6843f14a2270e2c4e80fd1a41a661974a (patch)
treeef7380b5961eb5d41393086ccd65ad1e093156c9 /lib
parent6f668186e69efca8fb063fdbeb6769dc2b14613a (diff)
Also silence network unreachable errors.
Diffstat (limited to 'lib')
-rw-r--r--lib/quiet_opener.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb
index bde645d0b..ae6605c43 100644
--- a/lib/quiet_opener.rb
+++ b/lib/quiet_opener.rb
@@ -3,7 +3,7 @@ require 'net-purge'
require 'net/http/local'
def quietly_try_to_open(url)
- begin
+ begin
result = open(url).read.strip
rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET
Rails.logger.warn("Unable to open third-party URL #{url}")
@@ -11,12 +11,12 @@ def quietly_try_to_open(url)
end
return result
end
-
+
def quietly_try_to_purge(host, url)
- begin
+ begin
result = ""
result_body = ""
- Net::HTTP.bind '127.0.0.1' do
+ Net::HTTP.bind '127.0.0.1' do
Net::HTTP.start(host) {|http|
request = Net::HTTP::Purge.new(url)
response = http.request(request)
@@ -24,7 +24,7 @@ def quietly_try_to_purge(host, url)
result_body = response.body
}
end
- rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET
+ rescue OpenURI::HTTPError, SocketError, Errno::ETIMEDOUT, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Errno::ECONNRESET, Errno::ENETUNREACH
Rails.logger.warn("PURGE: Unable to reach host #{host}")
end
if result == "200"
@@ -34,4 +34,4 @@ def quietly_try_to_purge(host, url)
end
return result
end
-
+