httpx 1.8.3 → 1.9.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 (82) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_8_4.md +13 -0
  3. data/doc/release_notes/1_9_0.md +75 -0
  4. data/lib/httpx/adapters/webmock.rb +1 -1
  5. data/lib/httpx/altsvc.rb +29 -15
  6. data/lib/httpx/callbacks.rb +2 -2
  7. data/lib/httpx/chainable.rb +6 -3
  8. data/lib/httpx/connection/http1.rb +11 -19
  9. data/lib/httpx/connection/http2.rb +112 -27
  10. data/lib/httpx/connection.rb +184 -46
  11. data/lib/httpx/headers.rb +2 -2
  12. data/lib/httpx/io/tcp.rb +18 -14
  13. data/lib/httpx/options.rb +86 -35
  14. data/lib/httpx/parser/http1.rb +3 -6
  15. data/lib/httpx/plugins/auth/digest.rb +1 -2
  16. data/lib/httpx/plugins/auth.rb +11 -2
  17. data/lib/httpx/plugins/aws_sdk_authentication.rb +7 -3
  18. data/lib/httpx/plugins/aws_sigv4.rb +1 -0
  19. data/lib/httpx/plugins/basic_auth.rb +2 -0
  20. data/lib/httpx/plugins/callbacks.rb +7 -6
  21. data/lib/httpx/plugins/circuit_breaker.rb +1 -0
  22. data/lib/httpx/plugins/cookies/cookie.rb +1 -1
  23. data/lib/httpx/plugins/cookies.rb +2 -2
  24. data/lib/httpx/plugins/digest_auth.rb +2 -0
  25. data/lib/httpx/plugins/expect.rb +2 -0
  26. data/lib/httpx/plugins/fiber_concurrency.rb +6 -0
  27. data/lib/httpx/plugins/follow_redirects.rb +8 -6
  28. data/lib/httpx/plugins/grpc/call.rb +4 -4
  29. data/lib/httpx/plugins/grpc/grpc_encoding.rb +2 -2
  30. data/lib/httpx/plugins/grpc.rb +21 -0
  31. data/lib/httpx/plugins/hedging.rb +284 -0
  32. data/lib/httpx/plugins/ntlm_auth.rb +1 -0
  33. data/lib/httpx/plugins/ntlm_v2_auth.rb +1 -0
  34. data/lib/httpx/plugins/oauth.rb +1 -1
  35. data/lib/httpx/plugins/proxy/http.rb +71 -16
  36. data/lib/httpx/plugins/proxy/ssh.rb +30 -11
  37. data/lib/httpx/plugins/proxy.rb +66 -45
  38. data/lib/httpx/plugins/push_promise.rb +4 -2
  39. data/lib/httpx/plugins/retries.rb +13 -3
  40. data/lib/httpx/plugins/server_sent_events.rb +2 -1
  41. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  42. data/lib/httpx/plugins/stream.rb +2 -2
  43. data/lib/httpx/plugins/tracing.rb +61 -14
  44. data/lib/httpx/plugins/upgrade/h2.rb +1 -1
  45. data/lib/httpx/plugins/upgrade.rb +2 -0
  46. data/lib/httpx/plugins/webdav.rb +8 -0
  47. data/lib/httpx/request/body.rb +2 -1
  48. data/lib/httpx/request.rb +10 -7
  49. data/lib/httpx/resolver/multi.rb +2 -2
  50. data/lib/httpx/resolver/resolver.rb +2 -2
  51. data/lib/httpx/resolver.rb +5 -1
  52. data/lib/httpx/response/body.rb +2 -2
  53. data/lib/httpx/response.rb +19 -11
  54. data/lib/httpx/selector.rb +3 -3
  55. data/lib/httpx/session.rb +38 -11
  56. data/lib/httpx/transcoder/chunker.rb +2 -2
  57. data/lib/httpx/transcoder/json.rb +7 -7
  58. data/lib/httpx/version.rb +1 -1
  59. data/sig/altsvc.rbs +3 -3
  60. data/sig/callbacks.rbs +1 -0
  61. data/sig/chainable.rbs +1 -0
  62. data/sig/connection/http1.rbs +1 -1
  63. data/sig/connection/http2.rbs +30 -16
  64. data/sig/connection.rbs +19 -1
  65. data/sig/headers.rbs +1 -1
  66. data/sig/httpx.rbs +2 -0
  67. data/sig/options.rbs +43 -12
  68. data/sig/parser/http1.rbs +1 -1
  69. data/sig/plugins/auth/digest.rbs +0 -1
  70. data/sig/plugins/auth.rbs +12 -5
  71. data/sig/plugins/hedging.rbs +44 -0
  72. data/sig/plugins/proxy/http.rbs +8 -1
  73. data/sig/plugins/proxy.rbs +3 -2
  74. data/sig/plugins/retries.rbs +2 -2
  75. data/sig/plugins/tracing.rbs +14 -5
  76. data/sig/request/body.rbs +1 -1
  77. data/sig/request.rbs +2 -1
  78. data/sig/resolver/entry.rbs +2 -2
  79. data/sig/response.rbs +1 -2
  80. data/sig/selector.rbs +2 -2
  81. data/sig/session.rbs +7 -5
  82. metadata +7 -1
@@ -0,0 +1,44 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Hedging
4
+ interface _HedgingOptions
5
+ def hedge_after: () -> (^(requestHedging request, Response response) -> interval | interval)?
6
+ end
7
+
8
+ module InstanceMethods
9
+ private
10
+
11
+ def hedge_connection: (connectionHedging connection) -> connectionHedging
12
+
13
+ def hedge_request!: (requestHedging request, connectionHedging connection, Selector selector) -> void
14
+
15
+ def when_to_hedge: (requestHedging request) -> interval?
16
+ end
17
+
18
+ module RequestMethods
19
+ attr_reader hedge_request: requestHedging?
20
+
21
+ @is_hedge_request: bool
22
+
23
+ def hedge_request=: (requestHedging? request) -> void
24
+ end
25
+
26
+ module ConnectionMethods
27
+ attr_reader hedge_connection: connectionHedging?
28
+
29
+ attr_accessor is_hedge_connection: bool
30
+
31
+ def hedge_connection=: (connectionHedging? connection) -> void
32
+
33
+ def try_yield_connection: [T] () { (connectionHedging) -> T } -> T
34
+ end
35
+ end
36
+ type optionsHedging = Options & Hedging::_HedgingOptions
37
+
38
+ type sessionHedging = Session & Hedging::InstanceMethods
39
+
40
+ type requestHedging = Request & Hedging::RequestMethods
41
+
42
+ type connectionHedging = Connection & Hedging::ConnectionMethods
43
+ end
44
+ end
@@ -2,6 +2,11 @@ module HTTPX
2
2
  module Plugins
3
3
  module Proxy
4
4
  module HTTP
5
+ module OptionsMethods
6
+ def proxy_headers: () -> Headers?
7
+
8
+ def enable_proxy_tunnel: () -> bool?
9
+ end
5
10
 
6
11
  module InstanceMethods
7
12
  def with_proxy_basic_auth: (Hash[Symbol, untyped] opts) -> instance
@@ -12,7 +17,9 @@ module HTTPX
12
17
  end
13
18
 
14
19
  module ConnectionMethods
15
- def __http_proxy_connect: (Connection::_Parser parser) -> void
20
+ @tunnel_parser: Connection::HTTP1 | Connection::HTTP2
21
+
22
+ def __http_proxy_connect: () -> void
16
23
  def __http_on_connect: (top, Response) -> void
17
24
  end
18
25
 
@@ -26,6 +26,7 @@ module HTTPX
26
26
 
27
27
  @ns: Integer
28
28
  @uris: Array[URI::Generic | String]
29
+ @initial_credentials: boolish
29
30
  @authenticator: _Authenticator
30
31
 
31
32
  def shift: () -> void
@@ -38,7 +39,7 @@ module HTTPX
38
39
 
39
40
  private
40
41
 
41
- def initialize: (?uri: generic_uri | Array[generic_uri], ?scheme: String, ?username: String, ?password: String, ?no_proxy: Array[generic_uri] | generic_uri, **untyped) -> void
42
+ def initialize: (?uri: generic_uri | Array[generic_uri], ?ns: Integer, ?scheme: String?, ?username: String?, ?password: String?, ?no_proxy: Array[generic_uri] | generic_uri | nil, **untyped) -> void
42
43
 
43
44
  def infer_default_auth_scheme: (URI::Generic uri) -> String?
44
45
 
@@ -58,7 +59,7 @@ module HTTPX
58
59
  end
59
60
 
60
61
  module InstanceMethods
61
- @__proxy_uris: Array[generic_uri]
62
+ @proxy_parameters: Parameters?
62
63
 
63
64
  private
64
65
 
@@ -45,11 +45,11 @@ module HTTPX
45
45
 
46
46
  def try_partial_retry: (retriesRequest request, retriesResponse response) -> void
47
47
 
48
- def prepare_to_retry: (retriesRequest request, retriesResponse response) -> void
48
+ def prepare_to_retry: (retriesRequest request, retriesResponse response, interval? retry_after) -> void
49
49
 
50
50
  def can_reconnect?: (retriesRequest request, retriesResponse response) -> bool
51
51
 
52
- def when_to_retry: (retriesRequest request, retriesResponse response, retriesOptions options) -> Numeric?
52
+ def when_to_retry: (retriesRequest request, retriesResponse response, retriesOptions options) -> interval?
53
53
  end
54
54
 
55
55
  module RequestMethods
@@ -2,13 +2,13 @@ module HTTPX
2
2
  module Plugins
3
3
  module Tracing
4
4
  interface _Tracer
5
- def enabled?: (retriesRequest request) -> boolish
5
+ def enabled?: (tracingRequest request) -> boolish
6
6
 
7
- def start: (retriesRequest request) -> void
7
+ def start: (tracingRequest request) -> void
8
8
 
9
- def reset: (retriesRequest request) -> void
9
+ def reset: (tracingRequest request) -> void
10
10
 
11
- def finish: (retriesRequest request, response response) -> void
11
+ def finish: (tracingRequest request, response response) -> void
12
12
  end
13
13
 
14
14
  class Wrapper
@@ -27,13 +27,22 @@ module HTTPX
27
27
 
28
28
  module RequestMethods
29
29
  attr_accessor init_time: Time?
30
+
31
+ attr_accessor handshake_time: Float?
30
32
  end
31
33
 
32
34
  module ConnectionMethods
33
35
  @init_time: Time?
34
36
  end
35
37
 
36
- type retriesRequest = Request & RequestMethods
38
+ module HTTP2Methods
39
+ @handshake_time: Float?
40
+ @handshake_init_time: Time
41
+
42
+ def send: (tracingRequest request, ?bool head) -> bool
43
+ end
44
+
45
+ type tracingRequest = Request & RequestMethods
37
46
  end
38
47
 
39
48
  type sessionTracing = Session
data/sig/request/body.rbs CHANGED
@@ -4,7 +4,7 @@ module HTTPX
4
4
 
5
5
  @headers: Headers
6
6
  @body: body_encoder?
7
- @unbounded_body: bool
7
+ @unbounded_body: bool?
8
8
 
9
9
  def initialize: (Headers h, Options options, **untyped) -> void
10
10
 
data/sig/request.rbs CHANGED
@@ -32,10 +32,11 @@ module HTTPX
32
32
  @query: String?
33
33
  @drainer: Enumerator[String, void]?
34
34
  @started: bool
35
+ @complete: bool
35
36
 
36
37
  def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
37
38
 
38
- def complete!: (?response response) -> void
39
+ def complete!: (?response response) -> bool
39
40
 
40
41
  def started?: () -> bool
41
42
 
@@ -4,10 +4,10 @@ module HTTPX
4
4
 
5
5
  @expires_in: interval
6
6
 
7
- def initialize: (IPAddr | _ToS address, ?Numeric expires_in, ?rescue_on_convert: boolish) -> void
7
+ def initialize: (ipaddr address, ?Numeric expires_in, ?rescue_on_convert: boolish) -> void
8
8
 
9
9
  def expired?: () -> bool
10
10
 
11
- def self.convert: (IPAddr | _ToS address) -> Resolver::Entry
11
+ def self.convert: (ipaddr address) -> Resolver::Entry
12
12
  end
13
13
  end
data/sig/response.rbs CHANGED
@@ -60,8 +60,7 @@ module HTTPX
60
60
  end
61
61
 
62
62
  class ContentType
63
- MIME_TYPE_RE: Regexp
64
- CHARSET_RE: Regexp
63
+ SPLIT_PATTERN: Regexp
65
64
 
66
65
  @header_value: String?
67
66
  @mime_type: String?
data/sig/selector.rbs CHANGED
@@ -44,9 +44,9 @@ module HTTPX
44
44
 
45
45
  def next_tick: () -> void
46
46
 
47
- def terminate: () -> void
47
+ def terminate: (?Array[selectable]) -> void
48
48
 
49
- def find_resolver: (Options options) -> Resolver::Resolver?
49
+ def find_resolver: (Options options) -> resolver?
50
50
 
51
51
  def find_connection: (http_uri request_uri, Options options) -> Connection?
52
52
 
data/sig/session.rbs CHANGED
@@ -15,8 +15,6 @@ module HTTPX
15
15
  @wrapped: bool
16
16
  @closing: bool
17
17
 
18
- type resolver = Resolver::Multi | Resolver::Resolver
19
-
20
18
  def wrap: () { (instance) -> void } -> void
21
19
 
22
20
  def close: (?Selector selector) -> void
@@ -42,15 +40,19 @@ module HTTPX
42
40
  def initialize: (?options) { (self) -> void } -> void
43
41
  | (?options) -> void
44
42
 
45
- def selector_close: (Selector close) -> void
43
+ def can_checkin?: (Connection connection) -> boolish
44
+
45
+ def selector_close: (Selector close, *untyped) -> void
46
46
 
47
- def deactivate: (Selector selector) -> void
47
+ def deactivate: (Selector selector, ?Exception? error) -> void
48
48
 
49
49
  def on_promise: (untyped, untyped) -> void
50
50
 
51
51
  def fetch_response: (Request request, Selector selector, Options options) -> response?
52
52
 
53
- def send_request: (Request request, Selector selector, ?Options options) -> void
53
+ def send_request: (Request request, Selector selector, ?Options options) ?{ (Connection) -> void } -> void
54
+
55
+ def do_request: (Request request, Connection connection, Selector selector) -> void
54
56
 
55
57
  def set_request_callbacks: (Request request) -> void
56
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
@@ -172,6 +172,8 @@ extra_rdoc_files:
172
172
  - doc/release_notes/1_8_1.md
173
173
  - doc/release_notes/1_8_2.md
174
174
  - doc/release_notes/1_8_3.md
175
+ - doc/release_notes/1_8_4.md
176
+ - doc/release_notes/1_9_0.md
175
177
  files:
176
178
  - LICENSE.txt
177
179
  - README.md
@@ -316,6 +318,8 @@ files:
316
318
  - doc/release_notes/1_8_1.md
317
319
  - doc/release_notes/1_8_2.md
318
320
  - doc/release_notes/1_8_3.md
321
+ - doc/release_notes/1_8_4.md
322
+ - doc/release_notes/1_9_0.md
319
323
  - lib/httpx.rb
320
324
  - lib/httpx/adapters/datadog.rb
321
325
  - lib/httpx/adapters/faraday.rb
@@ -371,6 +375,7 @@ files:
371
375
  - lib/httpx/plugins/grpc/grpc_encoding.rb
372
376
  - lib/httpx/plugins/grpc/message.rb
373
377
  - lib/httpx/plugins/h2c.rb
378
+ - lib/httpx/plugins/hedging.rb
374
379
  - lib/httpx/plugins/internal_telemetry.rb
375
380
  - lib/httpx/plugins/ntlm_auth.rb
376
381
  - lib/httpx/plugins/ntlm_v2_auth.rb
@@ -482,6 +487,7 @@ files:
482
487
  - sig/plugins/grpc/grpc_encoding.rbs
483
488
  - sig/plugins/grpc/message.rbs
484
489
  - sig/plugins/h2c.rbs
490
+ - sig/plugins/hedging.rbs
485
491
  - sig/plugins/ntlm_auth.rbs
486
492
  - sig/plugins/ntlm_v2_auth.rbs
487
493
  - sig/plugins/oauth.rbs