grac 4.3.1 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/grac/client.rb +39 -4
- data/lib/grac/version.rb +5 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 061003ad2cd97921474d31303c4257061bcc15836c47303149f73519757848cb
|
|
4
|
+
data.tar.gz: fc62c7fd354b21f7ea929870fbc2f69a0b3c4c7f838f10c4f501c451dba05db9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9f341acf25ddbf2e17551adfa3c7c75b0b157f06867c1b9f8aa62e141080eff04072598f0419ad1a9eab4c77d7b86934471db240a862e2ff856ccb2ae28d17e5
|
|
7
|
+
data.tar.gz: 54091341a2859c9a4fa98e8f253e24f7d0b34caa199a8dca476a9397c3934f38cfb31aa5f1db77632534dda5dcbd8d49f60e3baa151dcdfb4349bb6c8d7ca46a
|
data/lib/grac/client.rb
CHANGED
|
@@ -21,11 +21,13 @@ module Grac
|
|
|
21
21
|
params: options[:params] || {},
|
|
22
22
|
headers: {
|
|
23
23
|
'User-Agent' => "Grac v#{Grac::VERSION}",
|
|
24
|
-
'Content-Type' => 'application/json;charset=utf-8'
|
|
24
|
+
'Content-Type' => 'application/json;charset=utf-8',
|
|
25
25
|
}.merge(options[:headers] || {}),
|
|
26
26
|
postprocessing: {},
|
|
27
27
|
middleware: options[:middleware] || [],
|
|
28
28
|
retry_get_head: options.fetch(:retry_get_head, true),
|
|
29
|
+
proxy: options[:proxy],
|
|
30
|
+
ssl: options[:ssl],
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
if options[:postprocessing]
|
|
@@ -43,8 +45,8 @@ module Grac
|
|
|
43
45
|
|
|
44
46
|
@options.freeze
|
|
45
47
|
|
|
46
|
-
[:params, :headers, :postprocessing, :middleware].each do |k|
|
|
47
|
-
@options[k]
|
|
48
|
+
[:params, :headers, :postprocessing, :middleware, :proxy, :ssl].each do |k|
|
|
49
|
+
@options[k]&.freeze
|
|
48
50
|
end
|
|
49
51
|
|
|
50
52
|
@uri.freeze
|
|
@@ -55,6 +57,8 @@ module Grac
|
|
|
55
57
|
{
|
|
56
58
|
headers: @options[:headers].merge(options[:headers] || {}),
|
|
57
59
|
middleware: @options[:middleware] + (options[:middleware] || []),
|
|
60
|
+
proxy: merge_option_hash(options, :proxy),
|
|
61
|
+
ssl: merge_option_hash(options, :ssl),
|
|
58
62
|
},
|
|
59
63
|
)
|
|
60
64
|
|
|
@@ -85,12 +89,14 @@ module Grac
|
|
|
85
89
|
def call(opts, request_uri, method, params, body)
|
|
86
90
|
request_hash = {
|
|
87
91
|
method: method,
|
|
88
|
-
params: params,
|
|
92
|
+
params: params, # Query params are escaped by Typhoeus
|
|
89
93
|
body: body,
|
|
90
94
|
connecttimeout: opts[:connecttimeout],
|
|
91
95
|
timeout: opts[:timeout],
|
|
92
96
|
headers: opts[:headers],
|
|
93
97
|
}
|
|
98
|
+
apply_proxy_options(request_hash, opts[:proxy])
|
|
99
|
+
apply_ssl_options(request_hash, opts[:ssl])
|
|
94
100
|
|
|
95
101
|
request = ::Typhoeus::Request.new(request_uri, request_hash)
|
|
96
102
|
response = request.run
|
|
@@ -244,5 +250,34 @@ module Grac
|
|
|
244
250
|
CGI::escape(value).gsub('+', '%20')
|
|
245
251
|
end
|
|
246
252
|
|
|
253
|
+
def merge_option_hash(options, key)
|
|
254
|
+
existing = @options[key] || {}
|
|
255
|
+
new_val = options[key]
|
|
256
|
+
|
|
257
|
+
return existing if new_val == nil
|
|
258
|
+
|
|
259
|
+
existing.merge(new_val)
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
# map proxy options from our format to typhoeus format
|
|
263
|
+
def apply_proxy_options(request_hash, proxy)
|
|
264
|
+
return if proxy == nil
|
|
265
|
+
|
|
266
|
+
request_hash[:proxy] = proxy[:url] if proxy[:url] != nil
|
|
267
|
+
request_hash[:proxyusername] = proxy[:username] if proxy[:username] != nil
|
|
268
|
+
request_hash[:proxypassword] = proxy[:password] if proxy[:password] != nil
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# map ssl options from our format to typhoeus format
|
|
272
|
+
def apply_ssl_options(request_hash, ssl)
|
|
273
|
+
return if ssl == nil
|
|
274
|
+
|
|
275
|
+
request_hash[:ssl_verifypeer] = ssl[:verify_peer] if ssl[:verify_peer] != nil
|
|
276
|
+
request_hash[:ssl_verifyhost] = ssl[:verify_host] if ssl[:verify_host] != nil
|
|
277
|
+
request_hash[:sslcert] = ssl[:cert] if ssl[:cert] != nil
|
|
278
|
+
request_hash[:sslkey] = ssl[:key] if ssl[:key] != nil
|
|
279
|
+
request_hash[:cainfo] = ssl[:ca_info] if ssl[:ca_info] != nil
|
|
280
|
+
end
|
|
281
|
+
|
|
247
282
|
end
|
|
248
283
|
end
|
data/lib/grac/version.rb
CHANGED