Skip to content

Instantly share code, notes, and snippets.

@gschneider-r7
Last active April 13, 2017 05:04
Show Gist options
  • Save gschneider-r7/8f471638b023a240dcae to your computer and use it in GitHub Desktop.
Save gschneider-r7/8f471638b023a240dcae to your computer and use it in GitHub Desktop.
module Nexpose
class APIRequest
include XMLUtils
# Execute an API request (5th param used for gem version 5.3.0+)
def self.execute(url, req, api_version='1.1', options = {}, trust_store = nil)
options = {timeout: 6000000}
obj = self.new(req.to_s, url, api_version, trust_store)
obj.execute(options)
return obj
end
end
module AJAX
def self.https(nsc, timeout = nil)
http = Net::HTTP.new(nsc.host, nsc.port)
http.use_ssl = true
# changes for gem version 5.3.0+
if nsc.trust_store.nil?
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
else
http.cert_store = nsc.trust_store
end
http.read_timeout = 6000000
http.open_timeout = 6000000
http.continue_timeout = 6000000
http
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment