Class: Sonic::Protocol::HTTP
- Inherits:
-
Object
- Object
- Sonic::Protocol::HTTP
- Includes:
- Base
- Defined in:
- lib/sonic/protocols/http.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(service_checker) ⇒ HTTP
constructor
A new instance of HTTP.
Constructor Details
#initialize(service_checker) ⇒ HTTP
Returns a new instance of HTTP.
8 9 10 11 12 13 14 15 16 |
# File 'lib/sonic/protocols/http.rb', line 8 def initialize(service_checker) @service_checker = service_checker @http = Net::HTTP.new(service_checker.host, service_checker.port) if service_checker.protocol == :https @http.use_ssl = true @http.verify_mode = OpenSSL::SSL::VERIFY_NONE end @request = Net::HTTP::Get.new(service_checker.path) end |
Instance Method Details
#get ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sonic/protocols/http.rb', line 18 def get begin response = @http.request(@request) @service_checker.response = response.body case response.code when '200', '201', '202', '203', '204', '205', '206' true else @service_checker.error = response.error false end rescue Exception => e @service_checker.error = e.to_s false end end |