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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15cb5c2a1e8c6df4d82ead3b1185f981d556c94c1ec358fa868d83a7a2cfb643
4
- data.tar.gz: 7893ef6a779be11d71f8c5c7f468fd063ea41af0f6d63fbe3451c164e0fc3573
3
+ metadata.gz: 7a89de44525e89ca6ba5d2ec8803f0fbc514a8370177b356e40193ac7d751ed5
4
+ data.tar.gz: 07da86963520759b90a4f790ef30bc3e6cc637246d00e46ce9b1a2d8d5db490e
5
5
  SHA512:
6
- metadata.gz: ebdd1df7c1b70729affae816609537cf637f6e3ccf38f6533bba24f941e60bccccc21695f6f96bd0d14f1f96ae9579cddbfea7d552823af888d25906d994a4ba
7
- data.tar.gz: aa3e345d27836d891183909917679dc98520e0f0f9d64ce6c0d7588f521415ac26e7e94a63c4a328e5100a5e0e968a79aae3532ecce6df2b755e1a796bcba47a
6
+ metadata.gz: 7a3f31fc35a3f04b0ae8684ebf3b35e0c12c77a7b39d39ae470204f49bc3dbbfa56fa3dcfe8549f9f0c341b7044931f277aca3af1d3cfd993fce5488657a65ae
7
+ data.tar.gz: f5b1da1a268b751e0d6a5f07cd2033718573b94624bfdbcde7ee78255cd22f8e3e59356280f255b50684baee0d9790e9b567c8095235a116a5a29206b5a892c2
@@ -487,6 +487,7 @@ class NiceHttp
487
487
  end
488
488
  @auto_redirect = auto_redirect
489
489
  # for the case we have headers following nice_hash implementation
490
+ @headers_orig = @headers.dup
490
491
  @headers = @headers.generate
491
492
 
492
493
  self.class.active += 1
@@ -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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(arg)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(*arguments)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(*arguments)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(*arguments)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(argument)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(argument)
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 @prev_request[:contains_lambda]
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
- path, data, headers_t = manage_request(argument)
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
- @prev_request[:contains_lambda] = false
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz