summaryrefslogtreecommitdiff
path: root/lib/nickserver/adapters/celluloid_http.rb
blob: 92c5c534be2b244496085c4c15475ab742ced91c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'nickserver/adapters'
require 'nickserver/config'
silence_warnings do
  require 'celluloid/io'
end
require 'http'

module Nickserver::Adapters
  class CelluloidHttp
    silence_warnings do
      include Celluloid::IO
    end

    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