httpx 1.1.5 → 1.2.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -5
  3. data/doc/release_notes/1_2_0.md +49 -0
  4. data/lib/httpx/adapters/webmock.rb +25 -3
  5. data/lib/httpx/altsvc.rb +57 -2
  6. data/lib/httpx/chainable.rb +40 -29
  7. data/lib/httpx/connection/http1.rb +27 -22
  8. data/lib/httpx/connection/http2.rb +7 -3
  9. data/lib/httpx/connection.rb +45 -60
  10. data/lib/httpx/extensions.rb +0 -15
  11. data/lib/httpx/options.rb +84 -27
  12. data/lib/httpx/plugins/aws_sigv4.rb +2 -2
  13. data/lib/httpx/plugins/basic_auth.rb +1 -1
  14. data/lib/httpx/plugins/callbacks.rb +91 -0
  15. data/lib/httpx/plugins/circuit_breaker.rb +2 -0
  16. data/lib/httpx/plugins/cookies.rb +19 -9
  17. data/lib/httpx/plugins/digest_auth.rb +1 -1
  18. data/lib/httpx/plugins/follow_redirects.rb +11 -0
  19. data/lib/httpx/plugins/grpc.rb +2 -2
  20. data/lib/httpx/plugins/h2c.rb +20 -8
  21. data/lib/httpx/plugins/proxy/socks4.rb +2 -2
  22. data/lib/httpx/plugins/proxy/socks5.rb +2 -2
  23. data/lib/httpx/plugins/proxy.rb +14 -32
  24. data/lib/httpx/plugins/rate_limiter.rb +1 -1
  25. data/lib/httpx/plugins/retries.rb +4 -0
  26. data/lib/httpx/plugins/ssrf_filter.rb +142 -0
  27. data/lib/httpx/plugins/stream.rb +1 -1
  28. data/lib/httpx/plugins/upgrade/h2.rb +1 -1
  29. data/lib/httpx/plugins/upgrade.rb +1 -1
  30. data/lib/httpx/plugins/webdav.rb +1 -1
  31. data/lib/httpx/pool.rb +32 -28
  32. data/lib/httpx/request/body.rb +3 -3
  33. data/lib/httpx/request.rb +3 -5
  34. data/lib/httpx/resolver/https.rb +3 -2
  35. data/lib/httpx/resolver/native.rb +1 -0
  36. data/lib/httpx/resolver/resolver.rb +17 -6
  37. data/lib/httpx/session.rb +13 -82
  38. data/lib/httpx/timers.rb +3 -10
  39. data/lib/httpx/transcoder.rb +1 -1
  40. data/lib/httpx/version.rb +1 -1
  41. data/sig/altsvc.rbs +33 -0
  42. data/sig/chainable.rbs +1 -0
  43. data/sig/connection/http1.rbs +2 -1
  44. data/sig/connection.rbs +16 -16
  45. data/sig/options.rbs +10 -2
  46. data/sig/plugins/callbacks.rbs +38 -0
  47. data/sig/plugins/cookies.rbs +2 -0
  48. data/sig/plugins/follow_redirects.rbs +2 -0
  49. data/sig/plugins/proxy/socks4.rbs +2 -1
  50. data/sig/plugins/proxy/socks5.rbs +2 -1
  51. data/sig/plugins/proxy.rbs +11 -1
  52. data/sig/pool.rbs +1 -3
  53. data/sig/resolver/resolver.rbs +3 -1
  54. data/sig/session.rbs +4 -4
  55. metadata +10 -4
data/sig/connection.rbs CHANGED
@@ -44,25 +44,23 @@ module HTTPX
44
44
 
45
45
  def addresses: () -> Array[ipaddr]?
46
46
 
47
- def addresses=: (Array[ipaddr]) -> void
47
+ def addresses=: (Array[ipaddr] addresses) -> void
48
+
49
+ def send: (Request request) -> void
48
50
 
49
51
  def match?: (URI::Generic uri, Options options) -> bool
50
52
 
51
53
  def expired?: () -> boolish
52
54
 
53
- def mergeable?: (Connection) -> bool
55
+ def mergeable?: (Connection connection) -> bool
54
56
 
55
- def coalescable?: (Connection) -> bool
57
+ def coalescable?: (Connection connection) -> bool
56
58
 
57
59
  def create_idle: (?Hash[Symbol, untyped] options) -> Connection
58
60
 
59
- def merge: (Connection) -> void
60
-
61
- def purge_pending: () { (Request) -> void } -> void
62
-
63
- def match_altsvcs?: (URI::Generic uri) -> bool
61
+ def merge: (Connection connection) -> void
64
62
 
65
- def match_altsvc_options?: (URI::Generic uri, Options options) -> bool
63
+ def purge_pending: () { (Request request) -> void } -> void
66
64
 
67
65
  def connecting?: () -> bool
68
66
 
@@ -74,12 +72,12 @@ module HTTPX
74
72
 
75
73
  def call: () -> void
76
74
 
75
+ def terminate: () -> void
76
+
77
77
  def close: () -> void
78
78
 
79
79
  def reset: () -> void
80
80
 
81
- def send: (Request) -> void
82
-
83
81
  def timeout: () -> Numeric?
84
82
 
85
83
  def idling: () -> void
@@ -94,7 +92,9 @@ module HTTPX
94
92
 
95
93
  private
96
94
 
97
- def initialize: (io_type, URI::Generic, options) -> untyped
95
+ def initialize: (URI::Generic uri, options) -> void
96
+
97
+ def initialize_type: (URI::Generic uri, options) -> io_type
98
98
 
99
99
  def connect: () -> void
100
100
 
@@ -112,15 +112,15 @@ module HTTPX
112
112
 
113
113
  def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
114
114
 
115
- def transition: (Symbol) -> void
115
+ def transition: (Symbol nextstate) -> void
116
116
 
117
- def handle_transition: (Symbol) -> void
117
+ def handle_transition: (Symbol nextstate) -> void
118
118
 
119
119
  def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
120
120
 
121
- def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
121
+ def on_error: (HTTPX::TimeoutError | Error | StandardError error) -> void
122
122
 
123
- def handle_error: (StandardError) -> void
123
+ def handle_error: (StandardError error) -> void
124
124
 
125
125
  def purge_after_closed: () -> void
126
126
 
data/sig/options.rbs CHANGED
@@ -9,9 +9,11 @@ module HTTPX
9
9
  OPERATION_TIMEOUT: Integer
10
10
  KEEP_ALIVE_TIMEOUT: Integer
11
11
  SETTINGS_TIMEOUT: Integer
12
+ CLOSE_HANDSHAKE_TIMEOUT: Integer
12
13
  DEFAULT_OPTIONS: Hash[Symbol, untyped]
14
+ REQUEST_BODY_IVARS: Array[Symbol]
13
15
 
14
- type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
16
+ type timeout_type = :connect_timeout | :settings_timeout | :close_handshake_timeout | :operation_timeout | :keep_alive_timeout | :read_timeout | :write_timeout | :request_timeout
15
17
  type timeout = Hash[timeout_type, Numeric?]
16
18
 
17
19
  def self.new: (?options) -> instance
@@ -120,10 +122,16 @@ module HTTPX
120
122
  # ip_families
121
123
  attr_reader ip_families: Array[ip_family]
122
124
 
123
- def ==: (untyped other) -> bool
125
+ def ==: (Options other) -> bool
126
+
127
+ def options_equals?: (Options other, ?Array[Symbol] ignore_ivars) -> bool
128
+
124
129
  def merge: (_ToHash[Symbol, untyped] other) -> instance
130
+
125
131
  def to_hash: () -> Hash[Symbol, untyped]
126
132
 
133
+ def extend_with_plugin_classes: (Module pl) -> void
134
+
127
135
  private
128
136
 
129
137
  REQUEST_IVARS: Array[Symbol]
@@ -0,0 +1,38 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Callbacks
4
+ class CallbackError < Exception
5
+ end
6
+
7
+ module InstanceMethods
8
+ include HTTPX::Callbacks
9
+
10
+ type socket = TCPSocket | SSLSocket | UNIXSocket
11
+
12
+ def on_connection_opened: () { (http_uri origin, socket sock) -> void } -> self
13
+
14
+ def on_connection_closed: () { (http_uri origin) -> void } -> self
15
+
16
+ def on_request_error: () { (Request request, StandardError error) -> void } -> self
17
+
18
+ def on_request_started: () { (Request request) -> void } -> self
19
+
20
+ def on_request_body_chunk: () { (Request request, String chunk) -> void } -> self
21
+
22
+ def on_request_completed: () { (Request request) -> void } -> self
23
+
24
+ def on_response_started: () { (Request request, Response response) -> void } -> self
25
+
26
+ def on_response_body_chunk: () { (Request request, Response response, String chunk) -> void } -> self
27
+
28
+ def on_response_completed: () { (Request request, response response) -> void } -> self
29
+
30
+ private
31
+
32
+ def emit_or_callback_error: (*untyped) -> void
33
+ end
34
+ end
35
+
36
+ type sessionCallbacks = Session & Callbacks::InstanceMethods
37
+ end
38
+ end
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  interface _CookieOptions
7
7
  def cookies: () -> Jar?
8
+
9
+ def merge_cookie_in_jar: (Array[String] cookies, Jar jar) -> void
8
10
  end
9
11
 
10
12
  def self.extra_options: (Options) -> (Options & _CookieOptions)
@@ -12,6 +12,8 @@ module HTTPX
12
12
  def follow_insecure_redirects: () -> bool?
13
13
 
14
14
  def allow_auth_to_other_origins: () -> bool?
15
+
16
+ def redirect_on: (http_uri) -> bool?
15
17
  end
16
18
 
17
19
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
@@ -1,5 +1,6 @@
1
1
  module HTTPX
2
- Socks4Error: singleton(Error)
2
+ class Socks4Error < HTTPProxyError
3
+ end
3
4
 
4
5
  module Plugins
5
6
  module Proxy
@@ -1,5 +1,6 @@
1
1
  module HTTPX
2
- Socks5Error: singleton(Error)
2
+ class Socks5Error < HTTPProxyError
3
+ end
3
4
 
4
5
  module Plugins
5
6
  module Proxy
@@ -1,5 +1,8 @@
1
1
  module HTTPX
2
- class HTTPProxyError < Error
2
+ class HTTPProxyError < ConnectionError
3
+ end
4
+
5
+ class ProxySSL < SSL
3
6
  end
4
7
 
5
8
  module Plugins
@@ -36,6 +39,13 @@ module HTTPX
36
39
 
37
40
  module InstanceMethods
38
41
  @__proxy_uris: Array[generic_uri]
42
+
43
+ private
44
+
45
+ def proxy_error?: (Request request, response) -> bool
46
+ end
47
+
48
+ module ConnectionMethods
39
49
  end
40
50
  end
41
51
 
data/sig/pool.rbs CHANGED
@@ -6,8 +6,6 @@ module HTTPX
6
6
  @timers: Timers
7
7
  @selector: Selector
8
8
  @connections: Array[Connection]
9
- @eden_connections: Array[Connection]
10
- @connected_connections: Integer
11
9
 
12
10
  def empty?: () -> void
13
11
 
@@ -37,7 +35,7 @@ module HTTPX
37
35
 
38
36
  def register_connection: (Connection) -> void
39
37
 
40
- def unregister_connection: (Connection) -> void
38
+ def unregister_connection: (Connection, ?bool cleanup) -> void
41
39
 
42
40
  def select_connection: (Selector::selectable) -> void
43
41
 
@@ -14,6 +14,8 @@ module HTTPX
14
14
 
15
15
  def close: () -> void
16
16
 
17
+ alias terminate close
18
+
17
19
  def closed?: () -> bool
18
20
 
19
21
  def empty?: () -> bool
@@ -22,7 +24,7 @@ module HTTPX
22
24
 
23
25
  private
24
26
 
25
- def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses) -> void
27
+ def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
26
28
 
27
29
  def initialize: (ip_family? family, options options) -> void
28
30
 
data/sig/session.rbs CHANGED
@@ -33,7 +33,9 @@ module HTTPX
33
33
 
34
34
  def set_connection_callbacks: (Connection connection, Array[Connection] connections, Options options) -> void
35
35
 
36
- def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> Connection?
36
+ def set_request_callbacks: (Request request) -> void
37
+
38
+ def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> (Connection & AltSvc::ConnectionMixin)?
37
39
 
38
40
  def build_requests: (verb, uri, options) -> Array[Request]
39
41
  | (Array[[verb, uri, options]], options) -> Array[Request]
@@ -41,9 +43,7 @@ module HTTPX
41
43
  | (verb, _Each[[uri, options]], Options) -> Array[Request]
42
44
  | (verb, _Each[uri], options) -> Array[Request]
43
45
 
44
- def build_connection: (URI::HTTP | URI::HTTP uri, Options options) -> Connection
45
-
46
- def init_connection: (String type, URI::HTTP | URI::HTTP uri, Options options) -> Connection
46
+ def init_connection: (URI::HTTP | URI::HTTP uri, Options options) -> Connection
47
47
 
48
48
  def send_requests: (*Request) -> Array[response]
49
49
 
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.5
4
+ version: 1.2.0
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-23 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -137,6 +137,7 @@ extra_rdoc_files:
137
137
  - doc/release_notes/1_1_3.md
138
138
  - doc/release_notes/1_1_4.md
139
139
  - doc/release_notes/1_1_5.md
140
+ - doc/release_notes/1_2_0.md
140
141
  files:
141
142
  - LICENSE.txt
142
143
  - README.md
@@ -245,6 +246,7 @@ files:
245
246
  - doc/release_notes/1_1_3.md
246
247
  - doc/release_notes/1_1_4.md
247
248
  - doc/release_notes/1_1_5.md
249
+ - doc/release_notes/1_2_0.md
248
250
  - lib/httpx.rb
249
251
  - lib/httpx/adapters/datadog.rb
250
252
  - lib/httpx/adapters/faraday.rb
@@ -279,6 +281,7 @@ files:
279
281
  - lib/httpx/plugins/aws_sigv4.rb
280
282
  - lib/httpx/plugins/basic_auth.rb
281
283
  - lib/httpx/plugins/brotli.rb
284
+ - lib/httpx/plugins/callbacks.rb
282
285
  - lib/httpx/plugins/circuit_breaker.rb
283
286
  - lib/httpx/plugins/circuit_breaker/circuit.rb
284
287
  - lib/httpx/plugins/circuit_breaker/circuit_store.rb
@@ -309,6 +312,7 @@ files:
309
312
  - lib/httpx/plugins/response_cache/file_store.rb
310
313
  - lib/httpx/plugins/response_cache/store.rb
311
314
  - lib/httpx/plugins/retries.rb
315
+ - lib/httpx/plugins/ssrf_filter.rb
312
316
  - lib/httpx/plugins/stream.rb
313
317
  - lib/httpx/plugins/upgrade.rb
314
318
  - lib/httpx/plugins/upgrade/h2.rb
@@ -350,6 +354,7 @@ files:
350
354
  - lib/httpx/transcoder/xml.rb
351
355
  - lib/httpx/utils.rb
352
356
  - lib/httpx/version.rb
357
+ - sig/altsvc.rbs
353
358
  - sig/buffer.rbs
354
359
  - sig/callbacks.rbs
355
360
  - sig/chainable.rbs
@@ -377,6 +382,7 @@ files:
377
382
  - sig/plugins/aws_sigv4.rbs
378
383
  - sig/plugins/basic_auth.rbs
379
384
  - sig/plugins/brotli.rbs
385
+ - sig/plugins/callbacks.rbs
380
386
  - sig/plugins/circuit_breaker.rbs
381
387
  - sig/plugins/compression.rbs
382
388
  - sig/plugins/cookies.rbs
@@ -437,8 +443,8 @@ licenses:
437
443
  - Apache 2.0
438
444
  metadata:
439
445
  bug_tracker_uri: https://gitlab.com/os85/httpx/issues
440
- changelog_uri: https://os85.gitlab.io/httpx/#release-notes
441
- documentation_uri: https://os85.gitlab.io/httpx/rdoc/
446
+ changelog_uri: https://honeyryderchuck.gitlab.io/httpx/#release-notes
447
+ documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
442
448
  source_code_uri: https://gitlab.com/os85/httpx
443
449
  homepage_uri: https://honeyryderchuck.gitlab.io/httpx/
444
450
  rubygems_mfa_required: 'true'