class Heartcheck::Webservice::HttpClient
Http Client
Attributes
headers[R]
http[R]
open_timeout[R]
proxy[R]
read_timeout[R]
request[R]
uri[R]
Public Class Methods
new(url, proxy, ignore_ssl_cert, headers, open_timeout = nil, read_timeout = nil)
click to toggle source
# File lib/heartcheck/webservice/http_client.rb, line 8 def initialize(url, proxy, ignore_ssl_cert, headers, open_timeout = nil, read_timeout = nil) @uri = URI(url) @headers = headers || {} @proxy = URI(proxy) if proxy @http = Net::HTTP.new(@uri.host, @uri.port, proxy_host, proxy_port) @http.use_ssl = @uri.scheme == 'https' @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ignore_ssl_cert @http.open_timeout = open_timeout if open_timeout @http.read_timeout = read_timeout if read_timeout end
Public Instance Methods
get()
click to toggle source
# File lib/heartcheck/webservice/http_client.rb, line 20 def get @request = Net::HTTP::Get.new(uri.request_uri) headers.each { |k, v| request[k] = v } http.request request end
Private Instance Methods
proxy_host()
click to toggle source
# File lib/heartcheck/webservice/http_client.rb, line 30 def proxy_host proxy.host if proxy end
proxy_port()
click to toggle source
# File lib/heartcheck/webservice/http_client.rb, line 34 def proxy_port proxy.port if proxy end