ezclient 0.8.0 → 0.9.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
  SHA256:
3
- metadata.gz: 804fc50fb6a68cd558d225452a129fb9e9bbc90ed92e52585adc19b4bfb69229
4
- data.tar.gz: 957629df0aa314608e5437cbf522b7584252773aba6393f5d945366d31887e17
3
+ metadata.gz: ff7928f4cebba35f4a10b26e6cbc70610b1af5f09f15dfc681d59d8ba0f21bc6
4
+ data.tar.gz: 60e1dfd78d106d2b1267d6758164618833209723b321c967cc6590405a2fb9c2
5
5
  SHA512:
6
- metadata.gz: bfd99f38d5ff4599e07d4377775e9a1dacf59ff72d0a7c4617eba113e451292c901227cd3a6404a7300646fd5a21b759786dafdf49789dc73cf2ac5f5658c32a
7
- data.tar.gz: 18931394b14e281553ef176e436efbb424fda888eb8c674a0a5743bb2302558b9b38748a10d15d4bceea2afe568b4c452cbfa1d63d0002e2ff9aa4c17428095b
6
+ metadata.gz: 8c2d79e6882e9f9217b6b8e931cf4d9c153ac8e4ffb7190d738ca6d62dbc38f25ec05ecb7bdb884920933c6657762b32374a67769a7d99f7aa83e6fef449d0d6
7
+ data.tar.gz: eef52af42332607114392d2c6585abac380b73adca74a1e7da35f6d3f247c7cfed4bd7ea5dbdacbfdec4a090063a71d8bf54dfe0839f5293cf9a0fe500b42520
@@ -47,37 +47,41 @@ class EzClient::Request
47
47
  http_request.headers.to_h
48
48
  end
49
49
 
50
+ def http_options
51
+ @http_options ||= http_client.default_options.merge(ssl_context: options[:ssl_context])
52
+ end
53
+
50
54
  private
51
55
 
56
+ def http_request
57
+ @http_request ||= begin
58
+ # RUBY25: Hash#slice
59
+ opts = options.select { |key| [:json, :body, :headers].include?(key) }
60
+ opts[verb == "GET" ? :params : :form] = options[:params]
61
+ opts[:params] = options[:query] if options[:query]
62
+ opts[:form] = options[:form] if options[:form]
63
+
64
+ http_client.build_request(verb, url, opts)
65
+ end
66
+ end
67
+
52
68
  def http_client
69
+ # Only used to build proper HTTP::Request and HTTP::Options instances
53
70
  @http_client ||= begin
54
- client = options.fetch(:client) # TODO: dup?
71
+ client = options[:client].dup
55
72
  client = client.timeout(timeout) if timeout
56
73
  client = client.basic_auth(basic_auth) if basic_auth
57
74
  client
58
75
  end
59
76
  end
60
77
 
61
- def http_request
62
- @http_request ||= http_client.build_request(verb, url, http_options)
63
- end
64
-
65
- def http_options
66
- # RUBY25: Hash#slice
67
- opts = options.select { |key| [:json, :body, :headers].include?(key) }
68
- opts[verb == "GET" ? :params : :form] = options[:params]
69
- opts[:params] = options[:query] if options[:query]
70
- opts[:form] = options[:form] if options[:form]
71
- opts
72
- end
73
-
74
78
  def perform_request
75
79
  retries = 0
76
- request_options = http_client.default_options.merge(ssl_context: options[:ssl_context])
77
80
 
78
81
  begin
79
82
  retry_on_connection_error do
80
- http_client.perform(http_request, request_options)
83
+ client = options.fetch(:client) # Use original client so that connection can be reused
84
+ client.perform(http_request, http_options)
81
85
  end
82
86
  rescue *retried_exceptions
83
87
  if retries < max_retries.to_i
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzClient
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezclient
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov