nice_http 1.8.3 → 1.8.4
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/http_methods.rb +79 -23
- 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: 63d2aa02cbda4251da5f587839ccb8687b4180b7c6f1c5cfb0ea55b380439174
|
4
|
+
data.tar.gz: 74121e6dbb4b5416512a7fcce5588348163d0f1bbd9222be67c96a1a168f2354
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae869d887c91377e1a7fa0e590c7c92f0216511c21e9c42ee58dc5ae76f5df125a624b178eebd387669aff0acbe02e422a4972b1bc292609d1668427badfb193
|
7
|
+
data.tar.gz: af6d94e226fae1c06717d34f64406ed2271fcc03460da38415756b07ca2fc9fd571fd62697152f415a81d686a32db153177d000dbe93b5cc889618e242f5428e
|
@@ -86,9 +86,17 @@ module NiceHttpHttpMethods
|
|
86
86
|
@start_time_net = Time.now if @start_time_net.nil?
|
87
87
|
resp = @http.get(path, headers_t)
|
88
88
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
89
|
-
|
90
|
-
@headers_orig.each
|
91
|
-
|
89
|
+
try = false
|
90
|
+
@headers_orig.each do |k,v|
|
91
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
92
|
+
try = true
|
93
|
+
headers_t[k] = v.call
|
94
|
+
end
|
95
|
+
end
|
96
|
+
if try
|
97
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
98
|
+
resp = @http.get(path, headers_t)
|
99
|
+
end
|
92
100
|
end
|
93
101
|
data = resp.body
|
94
102
|
manage_response(resp, data)
|
@@ -211,9 +219,17 @@ module NiceHttpHttpMethods
|
|
211
219
|
resp = @http.post(path, data, headers_t)
|
212
220
|
#todo: do it also for forms and multipart
|
213
221
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
214
|
-
|
215
|
-
@headers_orig.each
|
216
|
-
|
222
|
+
try = false
|
223
|
+
@headers_orig.each do |k,v|
|
224
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
225
|
+
try = true
|
226
|
+
headers_t[k] = v.call
|
227
|
+
end
|
228
|
+
end
|
229
|
+
if try
|
230
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
231
|
+
resp = @http.post(path, data, headers_t)
|
232
|
+
end
|
217
233
|
end
|
218
234
|
data = resp.body
|
219
235
|
end
|
@@ -298,9 +314,17 @@ module NiceHttpHttpMethods
|
|
298
314
|
@start_time_net = Time.now if @start_time_net.nil?
|
299
315
|
resp = @http.send_request("PUT", path, data, headers_t)
|
300
316
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
301
|
-
|
302
|
-
@headers_orig.each
|
303
|
-
|
317
|
+
try = false
|
318
|
+
@headers_orig.each do |k,v|
|
319
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
320
|
+
try = true
|
321
|
+
headers_t[k] = v.call
|
322
|
+
end
|
323
|
+
end
|
324
|
+
if try
|
325
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
326
|
+
resp = @http.send_request("PUT", path, data, headers_t)
|
327
|
+
end
|
304
328
|
end
|
305
329
|
data = resp.body
|
306
330
|
rescue Exception => stack
|
@@ -370,9 +394,17 @@ module NiceHttpHttpMethods
|
|
370
394
|
@start_time_net = Time.now if @start_time_net.nil?
|
371
395
|
resp = @http.patch(path, data, headers_t)
|
372
396
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
373
|
-
|
374
|
-
@headers_orig.each
|
375
|
-
|
397
|
+
try = false
|
398
|
+
@headers_orig.each do |k,v|
|
399
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
400
|
+
try = true
|
401
|
+
headers_t[k] = v.call
|
402
|
+
end
|
403
|
+
end
|
404
|
+
if try
|
405
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
406
|
+
resp = @http.patch(path, data, headers_t)
|
407
|
+
end
|
376
408
|
end
|
377
409
|
data = resp.body
|
378
410
|
rescue Exception => stack
|
@@ -457,20 +489,36 @@ module NiceHttpHttpMethods
|
|
457
489
|
if data.to_s == ""
|
458
490
|
resp = @http.delete(path, headers_t)
|
459
491
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
460
|
-
|
461
|
-
@headers_orig.each
|
462
|
-
|
492
|
+
try = false
|
493
|
+
@headers_orig.each do |k,v|
|
494
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
495
|
+
try = true
|
496
|
+
headers_t[k] = v.call
|
497
|
+
end
|
498
|
+
end
|
499
|
+
if try
|
500
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
501
|
+
resp = @http.delete(path, headers_t)
|
502
|
+
end
|
463
503
|
end
|
464
504
|
else
|
465
505
|
request = Net::HTTP::Delete.new(path, headers_t)
|
466
506
|
request.body = data
|
467
507
|
resp = @http.request(request)
|
468
508
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
469
|
-
|
470
|
-
@headers_orig.each
|
471
|
-
|
472
|
-
|
473
|
-
|
509
|
+
try = false
|
510
|
+
@headers_orig.each do |k,v|
|
511
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
512
|
+
try = true
|
513
|
+
headers_t[k] = v.call
|
514
|
+
end
|
515
|
+
end
|
516
|
+
if try
|
517
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
518
|
+
request = Net::HTTP::Delete.new(path, headers_t)
|
519
|
+
request.body = data
|
520
|
+
resp = @http.request(request)
|
521
|
+
end
|
474
522
|
end
|
475
523
|
end
|
476
524
|
data = resp.body
|
@@ -526,9 +574,17 @@ module NiceHttpHttpMethods
|
|
526
574
|
@start_time_net = Time.now if @start_time_net.nil?
|
527
575
|
resp = @http.head(path, headers_t)
|
528
576
|
if resp.code == 401 and @headers_orig.values.map(&:class).include?(Proc)
|
529
|
-
|
530
|
-
@headers_orig.each
|
531
|
-
|
577
|
+
try = false
|
578
|
+
@headers_orig.each do |k,v|
|
579
|
+
if v.is_a?(Proc) and headers_t.key?(k)
|
580
|
+
try = true
|
581
|
+
headers_t[k] = v.call
|
582
|
+
end
|
583
|
+
end
|
584
|
+
if try
|
585
|
+
@logger.warn "Not authorized. Trying to generate a new token."
|
586
|
+
resp = @http.head(path, headers_t)
|
587
|
+
end
|
532
588
|
end
|
533
589
|
data = resp.body
|
534
590
|
rescue Exception => stack
|