nice_http 1.8.2 → 1.8.3
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/nice_http.rb +1 -0
- data/lib/nice_http/http_methods.rb +16 -14
- data/lib/nice_http/manage_request.rb +1 -2
- 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: 7a89de44525e89ca6ba5d2ec8803f0fbc514a8370177b356e40193ac7d751ed5
|
4
|
+
data.tar.gz: 07da86963520759b90a4f790ef30bc3e6cc637246d00e46ce9b1a2d8d5db490e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3f31fc35a3f04b0ae8684ebf3b35e0c12c77a7b39d39ae470204f49bc3dbbfa56fa3dcfe8549f9f0c341b7044931f277aca3af1d3cfd993fce5488657a65ae
|
7
|
+
data.tar.gz: f5b1da1a268b751e0d6a5f07cd2033718573b94624bfdbcde7ee78255cd22f8e3e59356280f255b50684baee0d9790e9b567c8095235a116a5a29206b5a892c2
|
data/lib/nice_http.rb
CHANGED
@@ -85,9 +85,9 @@ module NiceHttpHttpMethods
|
|
85
85
|
else
|
86
86
|
@start_time_net = Time.now if @start_time_net.nil?
|
87
87
|
resp = @http.get(path, headers_t)
|
88
|
-
if resp.code == 401 and @
|
88
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
89
89
|
@logger.warn "Not authorized. Trying to generate a new token."
|
90
|
-
|
90
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
91
91
|
resp = @http.get(path, headers_t)
|
92
92
|
end
|
93
93
|
data = resp.body
|
@@ -210,9 +210,9 @@ module NiceHttpHttpMethods
|
|
210
210
|
else
|
211
211
|
resp = @http.post(path, data, headers_t)
|
212
212
|
#todo: do it also for forms and multipart
|
213
|
-
if resp.code == 401 and @
|
213
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
214
214
|
@logger.warn "Not authorized. Trying to generate a new token."
|
215
|
-
|
215
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
216
216
|
resp = @http.post(path, data, headers_t)
|
217
217
|
end
|
218
218
|
data = resp.body
|
@@ -297,9 +297,9 @@ module NiceHttpHttpMethods
|
|
297
297
|
begin
|
298
298
|
@start_time_net = Time.now if @start_time_net.nil?
|
299
299
|
resp = @http.send_request("PUT", path, data, headers_t)
|
300
|
-
if resp.code == 401 and @
|
300
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
301
301
|
@logger.warn "Not authorized. Trying to generate a new token."
|
302
|
-
|
302
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
303
303
|
resp = @http.send_request("PUT", path, data, headers_t)
|
304
304
|
end
|
305
305
|
data = resp.body
|
@@ -369,9 +369,9 @@ module NiceHttpHttpMethods
|
|
369
369
|
begin
|
370
370
|
@start_time_net = Time.now if @start_time_net.nil?
|
371
371
|
resp = @http.patch(path, data, headers_t)
|
372
|
-
if resp.code == 401 and @
|
372
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
373
373
|
@logger.warn "Not authorized. Trying to generate a new token."
|
374
|
-
|
374
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
375
375
|
resp = @http.patch(path, data, headers_t)
|
376
376
|
end
|
377
377
|
data = resp.body
|
@@ -456,18 +456,20 @@ module NiceHttpHttpMethods
|
|
456
456
|
@start_time_net = Time.now if @start_time_net.nil?
|
457
457
|
if data.to_s == ""
|
458
458
|
resp = @http.delete(path, headers_t)
|
459
|
-
if resp.code == 401 and @
|
459
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
460
460
|
@logger.warn "Not authorized. Trying to generate a new token."
|
461
|
-
|
461
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
462
462
|
resp = @http.delete(path, headers_t)
|
463
463
|
end
|
464
464
|
else
|
465
465
|
request = Net::HTTP::Delete.new(path, headers_t)
|
466
466
|
request.body = data
|
467
467
|
resp = @http.request(request)
|
468
|
-
if resp.code == 401 and @
|
468
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
469
469
|
@logger.warn "Not authorized. Trying to generate a new token."
|
470
|
-
|
470
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
471
|
+
request = Net::HTTP::Delete.new(path, headers_t)
|
472
|
+
request.body = data
|
471
473
|
resp = @http.request(request)
|
472
474
|
end
|
473
475
|
end
|
@@ -523,9 +525,9 @@ module NiceHttpHttpMethods
|
|
523
525
|
begin
|
524
526
|
@start_time_net = Time.now if @start_time_net.nil?
|
525
527
|
resp = @http.head(path, headers_t)
|
526
|
-
if resp.code == 401 and @
|
528
|
+
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
527
529
|
@logger.warn "Not authorized. Trying to generate a new token."
|
528
|
-
|
530
|
+
@headers_orig.each { |k,v| headers_t[k] = v.call if v.is_a?(Proc)}
|
529
531
|
resp = @http.head(path, headers_t)
|
530
532
|
end
|
531
533
|
data = resp.body
|
@@ -13,7 +13,7 @@ module NiceHttpManageRequest
|
|
13
13
|
require "json"
|
14
14
|
|
15
15
|
@prev_request = Hash.new() if @prev_request.nil?
|
16
|
-
|
16
|
+
|
17
17
|
begin
|
18
18
|
content_type_included = false
|
19
19
|
path = ""
|
@@ -239,7 +239,6 @@ module NiceHttpManageRequest
|
|
239
239
|
# for lambdas
|
240
240
|
if v.is_a?(Proc)
|
241
241
|
headers_t[k] = v.call
|
242
|
-
@prev_request[:contains_lambda] = true
|
243
242
|
end
|
244
243
|
end
|
245
244
|
@prev_request[:path] = path
|