module Bosh::Monitor::Plugins::HttpRequestHelper

Public Instance Methods

send_http_get_request(uri) click to toggle source
# File lib/bosh/monitor/plugins/http_request_helper.rb, line 13
def send_http_get_request(uri)
  # we are interested in response, so send sync request
  logger.debug("Sending GET request to #{uri}")
  sync_client.get(uri)
end
send_http_post_request(uri, request) click to toggle source
# File lib/bosh/monitor/plugins/http_request_helper.rb, line 5
def send_http_post_request(uri, request)
  send_http_request(:post, uri, request)
end
send_http_put_request(uri, request) click to toggle source
# File lib/bosh/monitor/plugins/http_request_helper.rb, line 9
def send_http_put_request(uri, request)
  send_http_request(:put, uri, request)
end
send_http_request(method, uri, request) click to toggle source
# File lib/bosh/monitor/plugins/http_request_helper.rb, line 19
def send_http_request(method, uri, request)
  name = self.class.name
  logger.debug("sending HTTP #{method.to_s.upcase} to: #{uri}")
  started = Time.now
  http = EM::HttpRequest.new(uri).send(method, request)
  http.callback do
    logger.debug("#{name} event sent (took #{Time.now - started} seconds): #{http.response_header.status}")
  end

  http.errback do |e|
    logger.error("Failed to send #{name} event: #{e.error}")
  end
end

Private Instance Methods

sync_client() click to toggle source
# File lib/bosh/monitor/plugins/http_request_helper.rb, line 35
def sync_client
  client = HTTPClient.new
  client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
  client
end