aboutsummaryrefslogtreecommitdiffstats
path: root/lib/quiet_opener.rb
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2013-04-24 16:01:39 +0100
committerLouise Crow <louise.crow@gmail.com>2013-04-24 16:01:39 +0100
commitd3eec6f983f8524e28e8ffe42ba3a10efaa0a30e (patch)
tree4c9cd3a9709a18a46d179e4af63bc7bcfa117b66 /lib/quiet_opener.rb
parentcc3da49bc927175a49d7150b98d762f65e143d21 (diff)
parentd3aae5cc48c92473e06b2104bb9431305d5a92f0 (diff)
Merge branch 'release/0.9' into rails-3-develop
Conflicts: Gemfile.lock app/controllers/public_body_controller.rb app/mailers/track_mailer.rb app/views/request/_hidden_correspondence.html.erb app/views/request/_sidebar.html.erb app/views/request/hidden.html.erb app/views/request/new_please_describe.html.erb app/views/request/preview.html.erb app/views/user/show.html.erb config/environment.rb config/routes.rb spec/controllers/public_body_controller_spec.rb
Diffstat (limited to 'lib/quiet_opener.rb')
-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
-
+