httpx 1.2.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e5ee54988be76a44ae512da359d83c502f8a43073f244a116a8fdc45fa7b87d
4
- data.tar.gz: e3c08652a8d08eadbd1ef14b20005f93ff4131a712f8234c3eab94c7fce07167
3
+ metadata.gz: 7aff2acc77577cb1243c30a63766f404755131c2f1b19162b9b6ba13c49d61f8
4
+ data.tar.gz: 6297b0857edce0f5d93a0272c2b5e891257969c36cbf0c34c6a7ca6e4a5ced67
5
5
  SHA512:
6
- metadata.gz: 58f16e523d23215d89a8c873a5ce12491b52726073c334c4d9800e17e40dca8111ad43ab2467c37939a19bebbaa000c8db144fdbba87cc3d22cb699687df6699
7
- data.tar.gz: 64dd9bb70af4173339019b62fa9f54fdf3f22c4bf593b51fb3de624844ac8a599a51b49cae10623aee8b8cff24af4dee69e39bedfec7da3d1ae229d733632e9c
6
+ metadata.gz: 94da91dd14a8318e8f0a0199214f97c008b927c7b8d9f602f045434bbd375b4446c767ed805e424d826c3dc48e90a8a0fded192858d32763c4c38033e0107cae
7
+ data.tar.gz: 657cefe9a977ca56dddda02bbdb07a94b4a8f158193e5f0d695c254bdbcafd95ffccd29641d38958d16468a81fd236f4d95ef4487c335cf7e079fb29b8d456ba
@@ -0,0 +1,10 @@
1
+ # 1.2.2
2
+
3
+ ## Bugfixes
4
+
5
+ * only raise "unknown option" error when option is not supported, not anymore when error happens in the setup of a support option.
6
+ * usage of `HTTPX::Session#wrap` within a thread with other sessions using the `:persistent` plugin won't inadvertedly terminate its open connections.
7
+ * terminate connections on `IOError` (`SocketError` does not cover them).
8
+ * terminate connections on HTTP/2 protocol and handshake errors, which happen during establishment or termination of a HTTP/2 connection (they were being previously kept around, although they'd irrecoverable).
9
+ * `:oauth` plugin: fixing check preventing the OAuth metadata server integration path to be exercised.
10
+ * fix instantiation of the options headers object with the wrong headers class.
@@ -522,14 +522,15 @@ module HTTPX
522
522
  Errno::ENETUNREACH,
523
523
  Errno::EPIPE,
524
524
  Errno::ENOENT,
525
- SocketError => e
525
+ SocketError,
526
+ IOError => e
526
527
  # connect errors, exit gracefully
527
528
  error = ConnectionError.new(e.message)
528
529
  error.set_backtrace(e.backtrace)
529
530
  connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, error) : handle_error(error)
530
531
  @state = :closed
531
532
  emit(:close)
532
- rescue TLSError => e
533
+ rescue TLSError, HTTP2Next::Error::ProtocolError, HTTP2Next::Error::HandshakeError => e
533
534
  # connect errors, exit gracefully
534
535
  handle_error(e)
535
536
  connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, e) : handle_error(e)
data/lib/httpx/io/tcp.rb CHANGED
@@ -78,7 +78,8 @@ module HTTPX
78
78
  rescue Errno::ECONNREFUSED,
79
79
  Errno::EADDRNOTAVAIL,
80
80
  Errno::EHOSTUNREACH,
81
- SocketError => e
81
+ SocketError,
82
+ IOError => e
82
83
  raise e if @ip_index <= 0
83
84
 
84
85
  log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
data/lib/httpx/options.rb CHANGED
@@ -47,13 +47,13 @@ module HTTPX
47
47
  write_timeout: WRITE_TIMEOUT,
48
48
  request_timeout: REQUEST_TIMEOUT,
49
49
  },
50
+ :headers_class => Class.new(Headers),
50
51
  :headers => {},
51
52
  :window_size => WINDOW_SIZE,
52
53
  :buffer_size => BUFFER_SIZE,
53
54
  :body_threshold_size => MAX_BODY_THRESHOLD_SIZE,
54
55
  :request_class => Class.new(Request),
55
56
  :response_class => Class.new(Response),
56
- :headers_class => Class.new(Headers),
57
57
  :request_body_class => Class.new(Request::Body),
58
58
  :response_body_class => Class.new(Response::Body),
59
59
  :connection_class => Class.new(Connection),
@@ -154,7 +154,7 @@ module HTTPX
154
154
  end
155
155
 
156
156
  def option_headers(value)
157
- Headers.new(value)
157
+ headers_class.new(value)
158
158
  end
159
159
 
160
160
  def option_timeout(value)
@@ -342,12 +342,11 @@ module HTTPX
342
342
  defaults.each do |k, v|
343
343
  next if v.nil?
344
344
 
345
- begin
346
- value = __send__(:"option_#{k}", v)
347
- instance_variable_set(:"@#{k}", value)
348
- rescue NoMethodError
349
- raise Error, "unknown option: #{k}"
350
- end
345
+ option_method_name = :"option_#{k}"
346
+ raise Error, "unknown option: #{k}" unless respond_to?(option_method_name)
347
+
348
+ value = __send__(option_method_name, v)
349
+ instance_variable_set(:"@#{k}", value)
351
350
  end
352
351
  end
353
352
  end
@@ -60,9 +60,9 @@ module HTTPX
60
60
  end
61
61
 
62
62
  def load(http)
63
- return unless @token_endpoint && @token_endpoint_auth_method && @grant_type && @scope
63
+ return if @token_endpoint_auth_method && @grant_type && @scope
64
64
 
65
- metadata = http.get("#{issuer}/.well-known/oauth-authorization-server").raise_for_status.json
65
+ metadata = http.get("#{@issuer}/.well-known/oauth-authorization-server").raise_for_status.json
66
66
 
67
67
  @token_endpoint = metadata["token_endpoint"]
68
68
  @scope = metadata["scopes_supported"]
@@ -70,6 +70,7 @@ module HTTPX
70
70
  @token_endpoint_auth_method = Array(metadata["token_endpoint_auth_methods_supported"]).find do |am|
71
71
  SUPPORTED_AUTH_METHODS.include?(am)
72
72
  end
73
+ nil
73
74
  end
74
75
 
75
76
  def merge(other)
data/lib/httpx/pool.rb CHANGED
@@ -19,6 +19,17 @@ module HTTPX
19
19
  @connections = []
20
20
  end
21
21
 
22
+ def wrap
23
+ connections = @connections
24
+ @connections = []
25
+
26
+ begin
27
+ yield self
28
+ ensure
29
+ @connections.unshift(*connections)
30
+ end
31
+ end
32
+
22
33
  def empty?
23
34
  @connections.empty?
24
35
  end
data/lib/httpx/request.rb CHANGED
@@ -61,7 +61,7 @@ module HTTPX
61
61
  @uri = origin.merge("#{base_path}#{@uri}")
62
62
  end
63
63
 
64
- @headers = @options.headers_class.new(@options.headers)
64
+ @headers = @options.headers.dup
65
65
  @headers["user-agent"] ||= USER_AGENT
66
66
  @headers["accept"] ||= "*/*"
67
67
 
data/lib/httpx/session.rb CHANGED
@@ -28,13 +28,15 @@ module HTTPX
28
28
  # http.get("https://wikipedia.com")
29
29
  # end # wikipedia connection closes here
30
30
  def wrap
31
- begin
32
- prev_persistent = @persistent
33
- @persistent = true
34
- yield self
35
- ensure
36
- @persistent = prev_persistent
37
- close unless @persistent
31
+ prev_persistent = @persistent
32
+ @persistent = true
33
+ pool.wrap do
34
+ begin
35
+ yield self
36
+ ensure
37
+ @persistent = prev_persistent
38
+ close unless @persistent
39
+ end
38
40
  end
39
41
  end
40
42
 
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.2"
5
5
  end
data/sig/pool.rbs CHANGED
@@ -7,6 +7,8 @@ module HTTPX
7
7
  @selector: Selector
8
8
  @connections: Array[Connection]
9
9
 
10
+ def wrap: () { (instance) -> void } -> void
11
+
10
12
  def empty?: () -> void
11
13
 
12
14
  def next_tick: () -> void
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.2.1
4
+ version: 1.2.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: 2024-01-13 00:00:00.000000000 Z
11
+ date: 2024-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -139,6 +139,7 @@ extra_rdoc_files:
139
139
  - doc/release_notes/1_1_5.md
140
140
  - doc/release_notes/1_2_0.md
141
141
  - doc/release_notes/1_2_1.md
142
+ - doc/release_notes/1_2_2.md
142
143
  files:
143
144
  - LICENSE.txt
144
145
  - README.md
@@ -249,6 +250,7 @@ files:
249
250
  - doc/release_notes/1_1_5.md
250
251
  - doc/release_notes/1_2_0.md
251
252
  - doc/release_notes/1_2_1.md
253
+ - doc/release_notes/1_2_2.md
252
254
  - lib/httpx.rb
253
255
  - lib/httpx/adapters/datadog.rb
254
256
  - lib/httpx/adapters/faraday.rb