httpx 0.20.0 → 0.20.3

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: a5a31aeffa012bd1eea19c1e892c8669624de0d21c9cd8911ae025375f0b93fb
4
- data.tar.gz: 285707682eb2d1451106d28bc2d4a8ceb247d4237139c9e7d83bd5a0163b5a5c
3
+ metadata.gz: 543163347ad58a18829298d36113f88da710c5b139c14968962cdd88d9d36c86
4
+ data.tar.gz: 1a460e4e2f079f6b08ede7ad7076039ead2b6fc31cffb590e4c245d38e838dc5
5
5
  SHA512:
6
- metadata.gz: 6f2c50aa8895c6f07ed0acbca1b1171343da2b55bc838ae7f2a0f7a44300c101ea0020938946bf630b80ad6b81bed3cb54910b0734576b6e7c000e058497128c
7
- data.tar.gz: 83e19a86d841056821d9198c9a8e3e7b06ec354445289a1fd7d612d070b02b0a01aa9f45f5acdb0b35e4da413c2c3955646e5f55c5421db95879092a0a3aa377
6
+ metadata.gz: 7bf4ccdbefc71b868b51ff130cb0892791935dade7829ffe09b3401dbba112fd354a8781da8d58015afb254206ac8a5187477ac65bdaf09b996909ef2e42f93c
7
+ data.tar.gz: a06649e2a51aebe113e3604e739916f164a30aa643eb7e2a5f82871929d2ce1c9bb8b9f234c2ac2ce07f3bd995058e8ba7f1b42e5eaf5cb63fe205b753184b0b
@@ -1,4 +1,4 @@
1
- # 0.19.7
1
+ # 0.19.8
2
2
 
3
3
  ## Bugfixes
4
4
 
@@ -1,4 +1,4 @@
1
- # 0.19.0
1
+ # 0.20.0
2
2
 
3
3
  ## Features
4
4
 
@@ -0,0 +1,5 @@
1
+ # 0.20.1
2
+
3
+ ## Bugfixes
4
+
5
+ * bugfix for unregistering connections when timing out on DNS resolving; this wasn't happening, leaving a few cases where requests to the same domain timing out on resolution would hang on the second request.
@@ -0,0 +1,7 @@
1
+ # 0.20.2
2
+
3
+ ## Bugfixes
4
+
5
+ * fix for selector timeout errors closing all connections and ignoring resolvers.
6
+
7
+ Timeout errors on select were being propagated to all pooled connections, although not all of them were being selected on, and not all of them having timed out. plus, resolver timeouts were doing the same, making connections fail with connection timeout error, rather than resolve timeout error. A patch was implemented, where the selector now yields an error to the selected connections, rather than plain raising exception.
@@ -0,0 +1,6 @@
1
+ # 0.20.3
2
+
3
+ ## Bugfixes
4
+
5
+ * DoH resolver wasn't working for non-absolute (the large majority) of domains since v0.19.
6
+ * Allowing a single IP string to be passed to the resolver option `:nameserver` (just like the `resolv` library does), besides the already supported list of IPs.
@@ -276,6 +276,12 @@ module HTTPX
276
276
  @state == :open || @state == :inactive
277
277
  end
278
278
 
279
+ def raise_timeout_error(interval)
280
+ error = HTTPX::TimeoutError.new(interval, "timed out while waiting on select")
281
+ error.set_backtrace(caller)
282
+ on_error(error)
283
+ end
284
+
279
285
  private
280
286
 
281
287
  def connect
data/lib/httpx/io/ssl.rb CHANGED
@@ -145,12 +145,12 @@ module HTTPX
145
145
  "#{super}\n\n" \
146
146
  "SSL connection using #{@io.ssl_version} / #{Array(@io.cipher).first}\n" \
147
147
  "ALPN, server accepted to use #{protocol}\n" \
148
- "Server certificate:\n" \
149
- " subject: #{server_cert.subject}\n" \
150
- " start date: #{server_cert.not_before}\n" \
151
- " expire date: #{server_cert.not_after}\n" \
152
- " issuer: #{server_cert.issuer}\n" \
153
- " SSL certificate verify ok."
148
+ "Server certificate:\n " \
149
+ "subject: #{server_cert.subject}\n " \
150
+ "start date: #{server_cert.not_before}\n " \
151
+ "expire date: #{server_cert.not_after}\n " \
152
+ "issuer: #{server_cert.issuer}\n " \
153
+ "SSL certificate verify ok."
154
154
  end
155
155
  end
156
156
  end
data/lib/httpx/pool.rb CHANGED
@@ -80,6 +80,9 @@ module HTTPX
80
80
  connection.on(:activate) do
81
81
  select_connection(connection)
82
82
  end
83
+ connection.on(:close) do
84
+ unregister_connection(connection)
85
+ end
83
86
  end
84
87
 
85
88
  def deactivate(connections)
@@ -143,8 +146,6 @@ module HTTPX
143
146
 
144
147
  def on_resolver_error(connection, error)
145
148
  connection.emit(:error, error)
146
- # must remove connection by hand, hasn't been started yet
147
- unregister_connection(connection)
148
149
  end
149
150
 
150
151
  def on_resolver_close(resolver)
@@ -171,8 +172,7 @@ module HTTPX
171
172
 
172
173
  def unregister_connection(connection)
173
174
  @connections.delete(connection)
174
- deselect_connection(connection)
175
- @connected_connections -= 1
175
+ @connected_connections -= 1 if deselect_connection(connection)
176
176
  end
177
177
 
178
178
  def select_connection(connection)
@@ -39,6 +39,7 @@ module HTTPX
39
39
  @uri_addresses = nil
40
40
  @resolver = Resolv::DNS.new
41
41
  @resolver.timeouts = @resolver_options.fetch(:timeouts, Resolver::RESOLVE_TIMEOUT)
42
+ @resolver.lazy_initialize
42
43
  end
43
44
 
44
45
  def <<(connection)
@@ -45,7 +45,7 @@ module HTTPX
45
45
  super
46
46
  @ns_index = 0
47
47
  @resolver_options = DEFAULTS.merge(@options.resolver_options)
48
- @nameserver = @resolver_options[:nameserver]
48
+ @nameserver = Array(@resolver_options[:nameserver]) if @resolver_options[:nameserver]
49
49
  @ndots = @resolver_options[:ndots]
50
50
  @search = Array(@resolver_options[:search]).map { |srch| srch.scan(/[^.]+/) }
51
51
  @_timeouts = Array(@resolver_options[:timeouts])
@@ -118,6 +118,10 @@ module HTTPX
118
118
  @timeouts.values_at(*hosts).reject(&:empty?).map(&:first).min
119
119
  end
120
120
 
121
+ def raise_timeout_error(interval)
122
+ do_retry(interval)
123
+ end
124
+
121
125
  private
122
126
 
123
127
  def calculate_interests
@@ -134,10 +138,10 @@ module HTTPX
134
138
  dwrite if calculate_interests == :w
135
139
  end
136
140
 
137
- def do_retry
141
+ def do_retry(loop_time = nil)
138
142
  return if @queries.empty? || !@start_timeout
139
143
 
140
- loop_time = Utils.elapsed_time(@start_timeout)
144
+ loop_time ||= Utils.elapsed_time(@start_timeout)
141
145
 
142
146
  query = @queries.first
143
147
 
@@ -56,7 +56,7 @@ module HTTPX
56
56
 
57
57
  # :nocov:
58
58
  def inspect
59
- "#<Response:#{object_id} "\
59
+ "#<Response:#{object_id} " \
60
60
  "HTTP/#{version} " \
61
61
  "@status=#{@status} " \
62
62
  "@headers=#{@headers} " \
@@ -74,7 +74,10 @@ class HTTPX::Selector
74
74
 
75
75
  readers, writers = IO.select(r, w, nil, interval)
76
76
 
77
- raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil? && interval
77
+ if readers.nil? && writers.nil? && interval
78
+ [*r, *w].each { |io| io.raise_timeout_error(interval) }
79
+ return
80
+ end
78
81
  rescue IOError, SystemCallError
79
82
  @selectables.reject!(&:closed?)
80
83
  retry
@@ -108,7 +111,11 @@ class HTTPX::Selector
108
111
  when nil then return
109
112
  end
110
113
 
111
- raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") unless result || interval.nil?
114
+ unless result || interval.nil?
115
+ io.raise_timeout_error(interval)
116
+ return
117
+ end
118
+ # raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select")
112
119
 
113
120
  yield io
114
121
  rescue IOError, SystemCallError
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "0.20.0"
4
+ VERSION = "0.20.3"
5
5
  end
data/sig/connection.rbs CHANGED
@@ -72,6 +72,9 @@ module HTTPX
72
72
  def timeout: () -> Numeric?
73
73
 
74
74
  def deactivate: () -> void
75
+
76
+ def raise_timeout_error: (Numeric interval) -> void
77
+
75
78
  private
76
79
 
77
80
  def initialize: (String, URI::Generic, options) -> untyped
data/sig/pool.rbs CHANGED
@@ -36,9 +36,9 @@ module HTTPX
36
36
 
37
37
  def unregister_connection: (Connection) -> void
38
38
 
39
- def select_connection: (Resolver::Resolver | Connection connection) -> void
39
+ def select_connection: (Selector::selectable) -> void
40
40
 
41
- def deselect_connection: (Resolver::Resolver | Connection connection) -> void
41
+ def deselect_connection: (Selector::selectable) -> Selector::selectable?
42
42
 
43
43
  def coalesce_connections: (Connection coalescable, Connection coalescing) -> void
44
44
 
@@ -27,6 +27,8 @@ module HTTPX
27
27
 
28
28
  def timeout: () -> Numeric?
29
29
 
30
+ def raise_timeout_error: (Numeric interval) -> void
31
+
30
32
  private
31
33
 
32
34
  def initialize: (ip_family family, options options) -> void
@@ -35,7 +37,7 @@ module HTTPX
35
37
 
36
38
  def consume: () -> void
37
39
 
38
- def do_retry: () -> void
40
+ def do_retry: (?Numeric loop_time) -> void
39
41
 
40
42
  def dread: (Integer) -> void
41
43
  | () -> void
data/sig/selector.rbs CHANGED
@@ -7,7 +7,7 @@ module HTTPX
7
7
  @selectables: Array[selectable]
8
8
 
9
9
  def register: (selectable io) -> void
10
- def deregister: (selectable io) -> void
10
+ def deregister: (selectable io) -> selectable?
11
11
 
12
12
  def select: (Numeric? interval) { (selectable) -> void } -> void
13
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.20.0
4
+ version: 0.20.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-31 00:00:00.000000000 Z
11
+ date: 2022-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -81,6 +81,9 @@ extra_rdoc_files:
81
81
  - doc/release_notes/0_19_8.md
82
82
  - doc/release_notes/0_1_0.md
83
83
  - doc/release_notes/0_20_0.md
84
+ - doc/release_notes/0_20_1.md
85
+ - doc/release_notes/0_20_2.md
86
+ - doc/release_notes/0_20_3.md
84
87
  - doc/release_notes/0_2_0.md
85
88
  - doc/release_notes/0_2_1.md
86
89
  - doc/release_notes/0_3_0.md
@@ -154,6 +157,9 @@ files:
154
157
  - doc/release_notes/0_19_8.md
155
158
  - doc/release_notes/0_1_0.md
156
159
  - doc/release_notes/0_20_0.md
160
+ - doc/release_notes/0_20_1.md
161
+ - doc/release_notes/0_20_2.md
162
+ - doc/release_notes/0_20_3.md
157
163
  - doc/release_notes/0_2_0.md
158
164
  - doc/release_notes/0_2_1.md
159
165
  - doc/release_notes/0_3_0.md