Class: Heartcheck::Webservice::HttpClient
- Inherits:
-
Object
- Object
- Heartcheck::Webservice::HttpClient
- Defined in:
- lib/heartcheck/webservice/http_client.rb
Overview
Http Client
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#open_timeout ⇒ Object
readonly
Returns the value of attribute open_timeout.
-
#proxy ⇒ Object
readonly
Returns the value of attribute proxy.
-
#read_timeout ⇒ Object
readonly
Returns the value of attribute read_timeout.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(url, proxy, ignore_ssl_cert, headers, open_timeout = nil, read_timeout = nil) ⇒ HttpClient
constructor
A new instance of HttpClient.
Constructor Details
#initialize(url, proxy, ignore_ssl_cert, headers, open_timeout = nil, read_timeout = nil) ⇒ HttpClient
Returns a new instance of HttpClient.
8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def headers @headers end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def http @http end |
#open_timeout ⇒ Object (readonly)
Returns the value of attribute open_timeout.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def open_timeout @open_timeout end |
#proxy ⇒ Object (readonly)
Returns the value of attribute proxy.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def proxy @proxy end |
#read_timeout ⇒ Object (readonly)
Returns the value of attribute read_timeout.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def read_timeout @read_timeout end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def request @request end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
6 7 8 |
# File 'lib/heartcheck/webservice/http_client.rb', line 6 def uri @uri end |
Instance Method Details
#get ⇒ Object
20 21 22 23 24 25 26 |
# 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 |