summaryrefslogtreecommitdiff
path: root/lib/nickserver/adapters/http.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nickserver/adapters/http.rb')
-rw-r--r--lib/nickserver/adapters/http.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/nickserver/adapters/http.rb b/lib/nickserver/adapters/http.rb
index 636aceb..eb77cc6 100644
--- a/lib/nickserver/adapters/http.rb
+++ b/lib/nickserver/adapters/http.rb
@@ -2,6 +2,19 @@ require 'nickserver/adapters'
require 'nickserver/config'
require 'http'
+# Nickserver::Adapters::Http
+#
+# Basic http adapter with ssl and minimal error handling.
+# Only implemented get requests so far.
+#
+# Error Handling:
+#
+# Pass a string as the 'rescue' option. If a ConnectionError occures
+# which includes the string passed it will be rescued and the request
+# will return nil. This allows handling the error inside the adapter so
+# that for the derived CelluloidHttp Adapter the actor does not get
+# killed.
+
module Nickserver::Adapters
class Http
@@ -9,6 +22,8 @@ module Nickserver::Adapters
url = HTTP::URI.parse url.to_s
response = get_with_auth url, params: options[:query]
return response.code, response.to_s
+ rescue HTTP::ConnectionError => e
+ raise unless options[:rescue] && e.to_s.include?(options[:rescue])
end
protected