httpx 1.1.0 → 1.1.2
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/doc/release_notes/1_1_1.md +17 -0
- data/doc/release_notes/1_1_2.md +12 -0
- data/lib/httpx/adapters/sentry.rb +7 -2
- data/lib/httpx/connection/http1.rb +3 -3
- data/lib/httpx/connection.rb +9 -8
- data/lib/httpx/plugins/proxy/http.rb +0 -1
- data/lib/httpx/pool.rb +2 -7
- data/lib/httpx/resolver/resolver.rb +5 -2
- data/lib/httpx/resolver/system.rb +4 -1
- data/lib/httpx/resolver.rb +6 -4
- data/lib/httpx/session.rb +3 -1
- data/lib/httpx/timers.rb +2 -0
- data/lib/httpx/version.rb +1 -1
- data/sig/connection/http1.rbs +2 -2
- data/sig/resolver.rbs +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 118700ac0c350952382970ddb1ed33d74d954e1ddd6c2f82bb032cc24a3a5d22
|
4
|
+
data.tar.gz: 160644aeefb2ed61a8bda67b7896bbd2a4a4211cf9283ebe4e9a244ac237e780
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97d15923bd32a0378bcf54a147b37b308eda78a74f67f339467dd3130cffd0aab7dace5bb368dbf9f5a203f6bc73ea37db394e153107daaf3c81b389f269d849
|
7
|
+
data.tar.gz: 16e71f8eb94de6314a77b96620be5db341afa81f2fb026780bd467fa0aaa9aa3d395d3afca5f59ebbd3aae507b33c88d22a4c864e40bfa4b23031162a365bcb8
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# 1.1.1
|
2
|
+
|
3
|
+
## improvements
|
4
|
+
|
5
|
+
* (Re-)enabling default retries in DNS name queries; this had been disabled as a result of revamping timouts, and resulted in queries only being sent once, which is very little for UDP-related traffic, and breaks if using DNs rate-limiting software. Retries the query just once, for now.
|
6
|
+
|
7
|
+
## bugfixes
|
8
|
+
|
9
|
+
* reset timers when adding new intervals, as these may be added as a result on after-select connection handling, and must wait for the next tick cycle (before the patch, they were triggering too soon).
|
10
|
+
* fixed "on close" callback leak on connection reuse, which caused linear performance regression in benchmarks performing one request per connection.
|
11
|
+
* fixed hanging connection whan an HTTP/1.1 emitted a "connection: close" header but the server would not emit one (it closes the connection now).
|
12
|
+
* fixed recursive dns cached lookups which may have already expired, and created nil entries in the returned address list.
|
13
|
+
* dns system resolver is now able to retry on failure.
|
14
|
+
|
15
|
+
## chore
|
16
|
+
|
17
|
+
* remove duplicated callback unregitering connections.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# 1.1.2
|
2
|
+
|
3
|
+
## improvements
|
4
|
+
|
5
|
+
* only moving eden connections to idle when they're recycled.
|
6
|
+
|
7
|
+
## bugfixes
|
8
|
+
|
9
|
+
* skip closing a connection which is already closed during reset.
|
10
|
+
* sentry adapter: fixed `super` call which didn't have a super method (this prevented usinng sentry-enabled sessions with the `:retries` plugin).
|
11
|
+
* sentry adapter: fixing registering of sentry config.
|
12
|
+
* sentry adapter: do not propagate traces when relevant sdk options are disabled (such as `propagate_traces`).
|
@@ -27,6 +27,11 @@ module HTTPX::Plugins
|
|
27
27
|
def set_sentry_trace_header(request, sentry_span)
|
28
28
|
return unless sentry_span
|
29
29
|
|
30
|
+
config = ::Sentry.configuration
|
31
|
+
url = request.uri.to_s
|
32
|
+
|
33
|
+
return unless config.propagate_traces && config.trace_propagation_targets.any? { |target| url.match?(target) }
|
34
|
+
|
30
35
|
trace = ::Sentry.get_current_client.generate_sentry_trace(sentry_span)
|
31
36
|
request.headers[::Sentry::SENTRY_TRACE_HEADER_NAME] = trace if trace
|
32
37
|
end
|
@@ -91,7 +96,7 @@ module HTTPX::Plugins
|
|
91
96
|
|
92
97
|
module RequestMethods
|
93
98
|
def __sentry_enable_trace!
|
94
|
-
return
|
99
|
+
return if @__sentry_enable_trace
|
95
100
|
|
96
101
|
Tracer.call(self)
|
97
102
|
@__sentry_enable_trace = true
|
@@ -108,7 +113,7 @@ module HTTPX::Plugins
|
|
108
113
|
end
|
109
114
|
end
|
110
115
|
|
111
|
-
Sentry.register_patch do
|
116
|
+
Sentry.register_patch(:httpx) do
|
112
117
|
sentry_session = HTTPX.plugin(HTTPX::Plugins::Sentry)
|
113
118
|
|
114
119
|
HTTPX.send(:remove_const, :Session)
|
@@ -181,7 +181,7 @@ module HTTPX
|
|
181
181
|
if response.is_a?(ErrorResponse)
|
182
182
|
disable
|
183
183
|
else
|
184
|
-
manage_connection(response)
|
184
|
+
manage_connection(request, response)
|
185
185
|
end
|
186
186
|
|
187
187
|
if exhausted?
|
@@ -224,7 +224,7 @@ module HTTPX
|
|
224
224
|
|
225
225
|
private
|
226
226
|
|
227
|
-
def manage_connection(response)
|
227
|
+
def manage_connection(request, response)
|
228
228
|
connection = response.headers["connection"]
|
229
229
|
case connection
|
230
230
|
when /keep-alive/i
|
@@ -254,7 +254,7 @@ module HTTPX
|
|
254
254
|
disable
|
255
255
|
when nil
|
256
256
|
# In HTTP/1.1, it's keep alive by default
|
257
|
-
return if response.version == "1.1"
|
257
|
+
return if response.version == "1.1" && request.headers["connection"] != "close"
|
258
258
|
|
259
259
|
disable
|
260
260
|
end
|
data/lib/httpx/connection.rb
CHANGED
@@ -90,7 +90,7 @@ module HTTPX
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def match?(uri, options)
|
93
|
-
return false if @state == :closing || @state == :closed
|
93
|
+
return false if !used? && (@state == :closing || @state == :closed)
|
94
94
|
|
95
95
|
return false if exhausted?
|
96
96
|
|
@@ -273,7 +273,7 @@ module HTTPX
|
|
273
273
|
end
|
274
274
|
|
275
275
|
def timeout
|
276
|
-
return @timeout if
|
276
|
+
return @timeout if @timeout
|
277
277
|
|
278
278
|
return @options.timeout[:connect_timeout] if @state == :idle
|
279
279
|
|
@@ -503,10 +503,12 @@ module HTTPX
|
|
503
503
|
@origins |= [origin]
|
504
504
|
end
|
505
505
|
parser.on(:close) do |force|
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
506
|
+
if @state != :closed
|
507
|
+
transition(:closing)
|
508
|
+
if force || @state == :idle
|
509
|
+
transition(:closed)
|
510
|
+
emit(:close)
|
511
|
+
end
|
510
512
|
end
|
511
513
|
end
|
512
514
|
parser.on(:close_handshake) do
|
@@ -518,7 +520,6 @@ module HTTPX
|
|
518
520
|
else
|
519
521
|
transition(:closing)
|
520
522
|
transition(:closed)
|
521
|
-
emit(:reset)
|
522
523
|
|
523
524
|
@parser.reset if @parser
|
524
525
|
transition(:idle)
|
@@ -617,7 +618,7 @@ module HTTPX
|
|
617
618
|
def purge_after_closed
|
618
619
|
@io.close if @io
|
619
620
|
@read_buffer.clear
|
620
|
-
|
621
|
+
@timeout = nil
|
621
622
|
end
|
622
623
|
|
623
624
|
def build_socket(addrs = nil)
|
data/lib/httpx/pool.rb
CHANGED
@@ -110,6 +110,7 @@ module HTTPX
|
|
110
110
|
end
|
111
111
|
|
112
112
|
if conn
|
113
|
+
conn.idling
|
113
114
|
@connections << conn
|
114
115
|
select_connection(conn)
|
115
116
|
end
|
@@ -223,17 +224,11 @@ module HTTPX
|
|
223
224
|
@connected_connections += 1
|
224
225
|
end
|
225
226
|
select_connection(connection)
|
226
|
-
connection.on(:close) do
|
227
|
-
unregister_connection(connection)
|
228
|
-
end
|
229
227
|
end
|
230
228
|
|
231
229
|
def unregister_connection(connection)
|
232
230
|
@connections.delete(connection)
|
233
|
-
if connection.used? && !@eden_connections.include?(connection)
|
234
|
-
@eden_connections << connection
|
235
|
-
connection.idling
|
236
|
-
end
|
231
|
+
@eden_connections << connection if connection.used? && !@eden_connections.include?(connection)
|
237
232
|
@connected_connections -= 1 if deselect_connection(connection)
|
238
233
|
end
|
239
234
|
|
@@ -62,8 +62,11 @@ module HTTPX
|
|
62
62
|
addresses.first.to_s != connection.origin.host.to_s
|
63
63
|
log { "resolver: A response, applying resolution delay..." }
|
64
64
|
@pool.after(0.05) do
|
65
|
-
|
66
|
-
|
65
|
+
unless connection.state == :closed ||
|
66
|
+
# double emission check
|
67
|
+
(connection.addresses && addresses.intersect?(connection.addresses))
|
68
|
+
emit_resolved_connection(connection, addresses)
|
69
|
+
end
|
67
70
|
end
|
68
71
|
else
|
69
72
|
emit_resolved_connection(connection, addresses)
|
@@ -164,7 +164,8 @@ module HTTPX
|
|
164
164
|
def async_resolve(connection, hostname, scheme)
|
165
165
|
families = connection.options.ip_families
|
166
166
|
log { "resolver: query for #{hostname}" }
|
167
|
-
|
167
|
+
timeouts = @timeouts[connection.origin.host]
|
168
|
+
resolve_timeout = timeouts.first
|
168
169
|
|
169
170
|
Thread.start do
|
170
171
|
Thread.current.report_on_exception = false
|
@@ -191,6 +192,8 @@ module HTTPX
|
|
191
192
|
end
|
192
193
|
rescue StandardError => e
|
193
194
|
if e.is_a?(Timeout::Error)
|
195
|
+
timeouts.shift
|
196
|
+
retry unless timeouts.empty?
|
194
197
|
e = ResolveTimeoutError.new(resolve_timeout, e.message)
|
195
198
|
e.set_backtrace(e.backtrace)
|
196
199
|
end
|
data/lib/httpx/resolver.rb
CHANGED
@@ -5,7 +5,7 @@ require "ipaddr"
|
|
5
5
|
|
6
6
|
module HTTPX
|
7
7
|
module Resolver
|
8
|
-
RESOLVE_TIMEOUT =
|
8
|
+
RESOLVE_TIMEOUT = [2, 3].freeze
|
9
9
|
|
10
10
|
require "httpx/resolver/resolver"
|
11
11
|
require "httpx/resolver/system"
|
@@ -87,16 +87,18 @@ module HTTPX
|
|
87
87
|
def lookup(hostname, ttl)
|
88
88
|
return unless @lookups.key?(hostname)
|
89
89
|
|
90
|
-
@lookups[hostname] = @lookups[hostname].select do |address|
|
90
|
+
entries = @lookups[hostname] = @lookups[hostname].select do |address|
|
91
91
|
address["TTL"] > ttl
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
|
+
ips = entries.flat_map do |address|
|
94
95
|
if address.key?("alias")
|
95
96
|
lookup(address["alias"], ttl)
|
96
97
|
else
|
97
98
|
IPAddr.new(address["data"])
|
98
99
|
end
|
99
|
-
end
|
100
|
+
end.compact
|
101
|
+
|
100
102
|
ips unless ips.empty?
|
101
103
|
end
|
102
104
|
|
data/lib/httpx/session.rb
CHANGED
@@ -260,7 +260,9 @@ module HTTPX
|
|
260
260
|
connection.on(:open) do
|
261
261
|
emit(:connection_opened, connection.origin, connection.io.socket)
|
262
262
|
# only run close callback if it opened
|
263
|
-
|
263
|
+
end
|
264
|
+
connection.on(:close) do
|
265
|
+
emit(:connection_closed, connection.origin, connection.io.socket) if connection.used?
|
264
266
|
end
|
265
267
|
catch(:coalesced) do
|
266
268
|
pool.init_connection(connection, options)
|
data/lib/httpx/timers.rb
CHANGED
data/lib/httpx/version.rb
CHANGED
data/sig/connection/http1.rbs
CHANGED
@@ -59,13 +59,13 @@ module HTTPX
|
|
59
59
|
|
60
60
|
def initialize: (Buffer, options) -> untyped
|
61
61
|
|
62
|
-
def manage_connection: (Response) -> void
|
62
|
+
def manage_connection: (Request request, Response response) -> void
|
63
63
|
|
64
64
|
def disable: () -> void
|
65
65
|
|
66
66
|
def disable_pipelining: () -> void
|
67
67
|
|
68
|
-
def set_protocol_headers: (Request) -> _Each[[String, String]]
|
68
|
+
def set_protocol_headers: (Request request) -> _Each[[String, String]]
|
69
69
|
|
70
70
|
def handle: (Request request) -> void
|
71
71
|
|
data/sig/resolver.rbs
CHANGED
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: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -132,6 +132,8 @@ extra_rdoc_files:
|
|
132
132
|
- doc/release_notes/1_0_1.md
|
133
133
|
- doc/release_notes/1_0_2.md
|
134
134
|
- doc/release_notes/1_1_0.md
|
135
|
+
- doc/release_notes/1_1_1.md
|
136
|
+
- doc/release_notes/1_1_2.md
|
135
137
|
files:
|
136
138
|
- LICENSE.txt
|
137
139
|
- README.md
|
@@ -235,6 +237,8 @@ files:
|
|
235
237
|
- doc/release_notes/1_0_1.md
|
236
238
|
- doc/release_notes/1_0_2.md
|
237
239
|
- doc/release_notes/1_1_0.md
|
240
|
+
- doc/release_notes/1_1_1.md
|
241
|
+
- doc/release_notes/1_1_2.md
|
238
242
|
- lib/httpx.rb
|
239
243
|
- lib/httpx/adapters/datadog.rb
|
240
244
|
- lib/httpx/adapters/faraday.rb
|