diff options
Diffstat (limited to 'lib/nickserver/adapters')
-rw-r--r-- | lib/nickserver/adapters/celluloid_http.rb | 25 | ||||
-rw-r--r-- | lib/nickserver/adapters/em_http.rb | 24 |
2 files changed, 25 insertions, 24 deletions
diff --git a/lib/nickserver/adapters/celluloid_http.rb b/lib/nickserver/adapters/celluloid_http.rb new file mode 100644 index 0000000..d326b8a --- /dev/null +++ b/lib/nickserver/adapters/celluloid_http.rb @@ -0,0 +1,25 @@ +require 'nickserver/adapters' +silence_warnings do + require 'celluloid/io' +end +require 'http' + +module Nickserver::Adapters + class CelluloidHttp + include Celluloid::IO + + def get(url, options = {}) + response = HTTP.get url, + params: options[:query], + ssl_context: ctx, + ssl_socket_class: Celluloid::IO::SSLSocket + return response.code, response.to_s + end + + def ctx + OpenSSL::SSL::SSLContext.new.tap do |ctx| + ctx.ca_file = Nickserver::Config.hkp_ca_file + end + end + end +end diff --git a/lib/nickserver/adapters/em_http.rb b/lib/nickserver/adapters/em_http.rb deleted file mode 100644 index 16db5ae..0000000 --- a/lib/nickserver/adapters/em_http.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'nickserver/adapters' -require 'em-http' - -module Nickserver::Adapters - class EmHttp - - def initialize - @timeout = 5 - end - - def get(url, options = {}) - get_request(url, options).callback {|http| - yield http.response_header.status, http.response - }.errback {|http| - yield 0, http.error - } - end - - def get_request(url, options = {}) - @request = EventMachine::HttpRequest.new(url) - @request.get timeout: @timeout, query: options[:query] - end - end -end |