heartcheck-webservice 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85d95a9b12c2bb80fc047135b70e3a385271774e
4
- data.tar.gz: ef9f8312db964a9c4d6bd0a41b0d8556fec7e2ba
3
+ metadata.gz: 4aa666913efcada0341d6151bc41d38a2cbe63a4
4
+ data.tar.gz: 6729a0c04654b0e3da26b1e51292cf9607319649
5
5
  SHA512:
6
- metadata.gz: 513cf0300e92f97d86d356086ada4f39480c19f4af118c77c26b0baa4249e86880169b630032dd9bd95eaaedcbf292ffc462d48c99f2a1bd787b99b71200469a
7
- data.tar.gz: 4d0c97d8bec29a5223b24c6394a995fd59fb0efaa9d22ab33bf143a9ae92e8ecf12822d0f32a50d063112af8ad0d027b57b59de37ea2f8fb064a9aae5dbb4635
6
+ metadata.gz: 2ca3cb3fa2a895403ca0e84b9c2625367ed65ce80ba55d421790cbe95565c3bc8b87171c7692ced56b3879c8e890901ad4c7a3b4856bc313375171b71dcac0d3
7
+ data.tar.gz: 5f595137b7a1cb0c533e63e8b40a693bce902505b208ce2e8560f2e5405382738ab08bd43eb6abe4fc531dd0ca3c32080024e5f3e8a24c1ffcb0681d09861cf4
@@ -80,7 +80,9 @@ module Heartcheck
80
80
  # @return [Net:HTTP]
81
81
  def request_for(service)
82
82
  Heartcheck::Webservice::HttpClient.new(service[:url],
83
- service[:ignore_ssl_cert]).get
83
+ service[:proxy],
84
+ service[:ignore_ssl_cert],
85
+ service[:headers]).get
84
86
  end
85
87
  end
86
88
  end
@@ -3,17 +3,34 @@ module Heartcheck
3
3
  module Webservice
4
4
  # Http Client
5
5
  class HttpClient
6
- attr_reader :uri, :http
6
+ attr_reader :uri, :http, :proxy, :headers, :request
7
7
 
8
- def initialize(url, ignore_ssl_cert)
9
- @uri = URI url
10
- @http = Net::HTTP.new(@uri.host, @uri.port)
8
+ def initialize(url, proxy, ignore_ssl_cert, headers)
9
+ @uri = URI(url)
10
+ @headers = headers || {}
11
+ @proxy = URI(proxy) if proxy
12
+
13
+ @http = Net::HTTP.new(@uri.host, @uri.port, proxy_host, proxy_port)
11
14
  @http.use_ssl = @uri.scheme == 'https'
12
15
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ignore_ssl_cert
13
16
  end
14
17
 
15
18
  def get
16
- http.request Net::HTTP::Get.new(uri.request_uri)
19
+ @request = Net::HTTP::Get.new(uri.request_uri)
20
+
21
+ headers.each { |k, v| request[k] = v }
22
+
23
+ http.request request
24
+ end
25
+
26
+ private
27
+
28
+ def proxy_host
29
+ proxy.host if proxy
30
+ end
31
+
32
+ def proxy_port
33
+ proxy.port if proxy
17
34
  end
18
35
  end
19
36
  end
@@ -2,6 +2,6 @@
2
2
  module Heartcheck
3
3
  # gem version
4
4
  module Webservice
5
- VERSION = '1.1.0'
5
+ VERSION = '1.2.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heartcheck-webservice
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Locaweb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heartcheck