httpx 1.6.3 → 1.7.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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_11_0.md +3 -3
  3. data/doc/release_notes/1_6_3.md +2 -2
  4. data/doc/release_notes/1_7_0.md +149 -0
  5. data/lib/httpx/adapters/datadog.rb +1 -1
  6. data/lib/httpx/adapters/faraday.rb +1 -1
  7. data/lib/httpx/altsvc.rb +3 -1
  8. data/lib/httpx/connection/http1.rb +5 -6
  9. data/lib/httpx/connection/http2.rb +2 -0
  10. data/lib/httpx/connection.rb +3 -8
  11. data/lib/httpx/domain_name.rb +1 -1
  12. data/lib/httpx/headers.rb +2 -2
  13. data/lib/httpx/loggable.rb +2 -0
  14. data/lib/httpx/options.rb +40 -17
  15. data/lib/httpx/plugins/auth/digest.rb +44 -4
  16. data/lib/httpx/plugins/auth.rb +87 -4
  17. data/lib/httpx/plugins/aws_sdk_authentication.rb +0 -1
  18. data/lib/httpx/plugins/cookies/cookie.rb +1 -0
  19. data/lib/httpx/plugins/digest_auth.rb +4 -5
  20. data/lib/httpx/plugins/fiber_concurrency.rb +16 -1
  21. data/lib/httpx/plugins/grpc/grpc_encoding.rb +1 -1
  22. data/lib/httpx/plugins/grpc.rb +2 -2
  23. data/lib/httpx/plugins/internal_telemetry.rb +1 -1
  24. data/lib/httpx/plugins/ntlm_auth.rb +5 -3
  25. data/lib/httpx/plugins/oauth.rb +162 -56
  26. data/lib/httpx/plugins/rate_limiter.rb +2 -2
  27. data/lib/httpx/plugins/response_cache.rb +3 -7
  28. data/lib/httpx/plugins/retries.rb +55 -16
  29. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  30. data/lib/httpx/plugins/stream.rb +59 -8
  31. data/lib/httpx/plugins/stream_bidi.rb +73 -17
  32. data/lib/httpx/pool.rb +12 -2
  33. data/lib/httpx/request.rb +10 -1
  34. data/lib/httpx/resolver/https.rb +67 -17
  35. data/lib/httpx/resolver/multi.rb +4 -0
  36. data/lib/httpx/resolver/native.rb +26 -4
  37. data/lib/httpx/resolver/resolver.rb +2 -2
  38. data/lib/httpx/resolver.rb +97 -29
  39. data/lib/httpx/response/body.rb +2 -0
  40. data/lib/httpx/response.rb +22 -6
  41. data/lib/httpx/selector.rb +9 -0
  42. data/lib/httpx/session.rb +6 -6
  43. data/lib/httpx/transcoder/body.rb +1 -1
  44. data/lib/httpx/transcoder/json.rb +1 -1
  45. data/lib/httpx/transcoder/multipart/decoder.rb +4 -4
  46. data/lib/httpx/transcoder/multipart/encoder.rb +1 -1
  47. data/lib/httpx/transcoder/multipart.rb +16 -8
  48. data/lib/httpx/transcoder.rb +4 -6
  49. data/lib/httpx/version.rb +1 -1
  50. data/sig/altsvc.rbs +3 -0
  51. data/sig/chainable.rbs +3 -3
  52. data/sig/connection.rbs +1 -3
  53. data/sig/options.rbs +1 -1
  54. data/sig/plugins/auth/digest.rbs +6 -0
  55. data/sig/plugins/auth.rbs +28 -4
  56. data/sig/plugins/basic_auth.rbs +3 -3
  57. data/sig/plugins/digest_auth.rbs +2 -4
  58. data/sig/plugins/fiber_concurrency.rbs +6 -0
  59. data/sig/plugins/ntlm_auth.rbs +2 -2
  60. data/sig/plugins/oauth.rbs +46 -15
  61. data/sig/plugins/rate_limiter.rbs +1 -1
  62. data/sig/plugins/response_cache/file_store.rbs +2 -0
  63. data/sig/plugins/response_cache.rbs +4 -0
  64. data/sig/plugins/retries.rbs +8 -2
  65. data/sig/plugins/stream.rbs +13 -3
  66. data/sig/plugins/stream_bidi.rbs +2 -2
  67. data/sig/pool.rbs +1 -1
  68. data/sig/resolver/https.rbs +5 -0
  69. data/sig/resolver/multi.rbs +2 -0
  70. data/sig/resolver/native.rbs +2 -0
  71. data/sig/resolver.rbs +12 -3
  72. data/sig/response.rbs +3 -0
  73. data/sig/session.rbs +3 -5
  74. data/sig/transcoder/multipart.rbs +4 -2
  75. data/sig/transcoder.rbs +5 -1
  76. metadata +3 -1
@@ -43,6 +43,12 @@ module HTTPX
43
43
  end
44
44
  end
45
45
 
46
+ module FiberConcurrencyStream
47
+ module StreamResponseMethods
48
+ def close: () -> void
49
+ end
50
+ end
51
+
46
52
  type request = Request & RequestMethods
47
53
  end
48
54
 
@@ -8,7 +8,7 @@ module HTTPX
8
8
 
9
9
  def self.extra_options: (Options) -> (Options & _NTLMOptions)
10
10
 
11
- def self.load_dependencies: (*untyped) -> void
11
+ def self.load_dependencies: (singleton(Session) klass) -> void
12
12
 
13
13
  module InstanceMethods
14
14
  def ntlm_auth: (string user, string password, ?string? domain) -> instance
@@ -16,6 +16,6 @@ module HTTPX
16
16
 
17
17
  end
18
18
 
19
- type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
19
+ type sessionNTLMAuth = sessionAuth & NTLMAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -15,19 +15,18 @@ module HTTPX
15
15
  SUPPORTED_AUTH_METHODS: ::Array[token_auth_method]
16
16
 
17
17
  class OAuthSession
18
- attr_reader grant_type: grant_type
19
-
20
- attr_reader client_id: String
21
-
22
- attr_reader client_secret: String
23
-
24
18
  attr_reader access_token: String?
25
19
 
26
20
  attr_reader refresh_token: String?
27
21
 
28
- attr_reader scope: Array[String]?
29
-
30
- attr_reader audience: String?
22
+ @issuer: http_uri
23
+ @grant_type: grant_type
24
+ @client_id: String
25
+ @client_secret: String
26
+ @token_endpoint: http_uri?
27
+ @scope: Array[String]?
28
+ @audience: String?
29
+ @token_endpoint_auth_method: String?
31
30
 
32
31
  def initialize: (
33
32
  issuer: uri,
@@ -37,32 +36,64 @@ module HTTPX
37
36
  ?refresh_token: String?,
38
37
  ?scope: (Array[String] | String)?,
39
38
  ?token_endpoint: String?,
40
- ?response_type: String?,
41
39
  ?grant_type: String?,
42
40
  ?token_endpoint_auth_method: ::String,
43
41
  ?audience: ::String
44
42
  ) -> void
45
43
 
46
- def token_endpoint: () -> String
44
+ def token_endpoint: () -> uri
45
+
46
+ def token_endpoint_auth_method: () -> String
47
47
 
48
- def token_endpoint_auth_method: () -> token_auth_method
48
+ def reset!: () -> void
49
49
 
50
- def load: (Session http) -> void
50
+ def fetch_access_token: (sessionOAuth http) -> String
51
51
 
52
52
  def merge: (instance | Hash[untyped, untyped] other) -> instance
53
+
54
+ private
55
+
56
+
57
+ def load: (sessionOAuth http) -> void
53
58
  end
54
59
 
55
- interface _AwsSdkOptions
60
+ interface _OAuthOptions
56
61
  def oauth_session: () -> OAuthSession?
62
+
63
+ def oauth_options: () -> {
64
+ issuer: uri,
65
+ client_id: String,
66
+ client_secret: String,
67
+ ?access_token: String?,
68
+ ?refresh_token: String?,
69
+ ?scope: (Array[String] | String)?,
70
+ ?token_endpoint: String?,
71
+ ?response_type: String?,
72
+ ?grant_type: String?,
73
+ ?token_endpoint_auth_method: ::String,
74
+ ?audience: ::String
75
+ }?
57
76
  end
58
77
 
59
78
  module InstanceMethods
79
+ attr_reader oauth_session: OAuthSession
80
+ @options: Options & _OAuthOptions
81
+
60
82
  def oauth_auth: (**untyped args) -> instance
61
83
 
62
84
  def with_access_token: () -> instance
85
+
86
+ def refresh_oauth_tokens!: () -> void
87
+ end
88
+
89
+ module OAuthRetries
90
+ def self?.response_oauth_error?: (response res) -> bool
91
+
92
+ module InstanceMethods
93
+ end
63
94
  end
64
95
  end
65
96
 
66
- type sessionOAuth = Session & OAuth::InstanceMethods
97
+ type sessionOAuth = Session & Auth::InstanceMethods & OAuth::InstanceMethods
67
98
  end
68
99
  end
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.load_dependencies: (singleton(Session)) -> void
7
7
 
8
- def self.retry_on_rate_limited_response: (_Response) -> bool
8
+ def self.retry_on_rate_limited_response?: (_Response) -> bool
9
9
 
10
10
  def self.retry_after_rate_limit: (untyped, response) -> Numeric?
11
11
  end
@@ -2,6 +2,8 @@ module HTTPX
2
2
  module Plugins
3
3
  module ResponseCache
4
4
  class FileStore
5
+ CRLF: String
6
+
5
7
  @dir: Pathname
6
8
 
7
9
  include _ResponseCacheStore
@@ -39,6 +39,7 @@ module HTTPX
39
39
 
40
40
  module RequestMethods
41
41
  attr_accessor cached_response: cacheResponse?
42
+ attr_reader options: cacheOptions
42
43
 
43
44
  @response_cache_key: String
44
45
 
@@ -51,6 +52,9 @@ module HTTPX
51
52
  attr_writer original_request: cacheRequest
52
53
 
53
54
  @cache: bool
55
+ @cache_control: Array[String]?
56
+ @vary: Array[String]?
57
+ @date: Time?
54
58
 
55
59
  def original_request: () -> cacheRequest?
56
60
 
@@ -6,13 +6,18 @@ module HTTPX
6
6
  RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
7
7
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
8
8
  DEFAULT_JITTER: ^(Numeric) -> Numeric
9
+ BACKOFF_ALGORITHMS: Array[Symbol]
10
+
11
+ def self?.retry_after_polynomial_backoff: (retriesRequest request, response response) -> Numeric
12
+
13
+ def self?.retry_after_exponential_backoff: (retriesRequest request, response response) -> Numeric
9
14
 
10
15
  interface _RetryCallback
11
16
  def call: (response response) -> bool?
12
17
  end
13
18
 
14
19
  interface _RetriesOptions
15
- def retry_after: () -> Numeric?
20
+ def retry_after: () -> (^(retriesRequest request, response response) -> Numeric | Numeric)?
16
21
 
17
22
  def retry_jitter: () -> ^(Numeric jitter) -> Numeric
18
23
 
@@ -38,10 +43,11 @@ module HTTPX
38
43
 
39
44
  def try_partial_retry: (retriesRequest request, (retriesResponse | ErrorResponse) response) -> void
40
45
 
46
+ def prepare_to_retry: (Request & RequestMethods request, response response) -> void
41
47
  end
42
48
 
43
49
  module RequestMethods
44
- @options: Options & _RetriesOptions
50
+ attr_reader options: retriesOptions
45
51
 
46
52
  attr_accessor retries: Integer
47
53
 
@@ -1,11 +1,21 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Stream
4
+ STREAM_REQUEST_OPTIONS: Hash[Symbol, untyped]
5
+
6
+ interface _StreamOptions
7
+ def stream: () -> boolish
8
+
9
+ def retry_stream_response_class: () -> singleton(StreamResponse)
10
+ end
11
+
4
12
  module InstanceMethods
13
+ @options: Options & _StreamOptions
14
+
5
15
  private
6
16
 
7
- def request: (*Request, ?stream: bool, **untyped?) -> (response | Array[response] | StreamResponse)
8
- | (*untyped, ?stream: bool, **untyped?) -> (response | Array[response] | StreamResponse)
17
+ def request: (*Request, **untyped?) -> (response | Array[response] | StreamResponse)
18
+ | (*untyped, **untyped?) -> (response | Array[response] | StreamResponse)
9
19
  end
10
20
 
11
21
  module RequestMethods
@@ -30,7 +40,7 @@ module HTTPX
30
40
  type streamRequest = Request & Plugins::Stream::RequestMethods
31
41
 
32
42
  attr_reader request: streamRequest
33
- @options: Options
43
+ @options: Options & _StreamOptions
34
44
 
35
45
  @session: Plugins::sessionStream
36
46
  @response_enum: Enumerator[String]?
@@ -16,7 +16,7 @@ module HTTPX
16
16
  end
17
17
 
18
18
  class BidiBuffer < Buffer
19
- @parent_thread: Thread
19
+ @buffer_mutex: Thread::Mutex
20
20
  @oob_mutex: Thread::Mutex
21
21
  @oob_buffer: String
22
22
 
@@ -34,7 +34,7 @@ module HTTPX
34
34
 
35
35
  def wakeup: () -> void
36
36
 
37
- def mergeable?: () -> bool
37
+ def inflight?: () -> bool
38
38
 
39
39
  def terminate: () -> void
40
40
  end
data/sig/pool.rbs CHANGED
@@ -15,7 +15,7 @@ module HTTPX
15
15
  @options: Options
16
16
  @resolvers: Hash[Class, Array[resolver_manager]]
17
17
  @resolver_mtx: Thread::Mutex
18
- @connections: Hash[String, Array[Connection]]
18
+ @connections: Array[Connection]
19
19
  @connection_mtx: Thread::Mutex
20
20
  @connections_counter: Integer
21
21
  @max_connections_cond: ConditionVariable
@@ -11,11 +11,14 @@ module HTTPX
11
11
  attr_reader family: ip_family
12
12
 
13
13
  @options: Options
14
+ @_timeouts: Array[Numeric]
15
+ @timeouts: Hash[String, Array[Numeric]]
14
16
  @queries: Hash[String, Connection]
15
17
  @requests: Hash[Request, String]
16
18
  @connections: Array[Connection]
17
19
  @uri: http_uri
18
20
  @uri_addresses: Array[String]?
21
+ @name: String?
19
22
  @resolver: Resolv::DNS
20
23
  @resolver_connection: Connection
21
24
 
@@ -29,6 +32,8 @@ module HTTPX
29
32
 
30
33
  def resolver_connection: () -> Connection
31
34
 
35
+ def send_request: (String hostname, Connection connection) -> void
36
+
32
37
  def on_response: (Request, response) -> void
33
38
 
34
39
  def parse: (Request request, Response response) -> void
@@ -9,6 +9,8 @@ module HTTPX
9
9
  @current_session: Session?
10
10
  @resolver_options: Hash[Symbol, untyped]
11
11
 
12
+ def state: () -> String
13
+
12
14
  def current_selector=: (Selector s) -> void
13
15
 
14
16
  def current_session=: (Session s) -> void
@@ -64,6 +64,8 @@ module HTTPX
64
64
 
65
65
  def transition: (Symbol nextstate) -> void
66
66
 
67
+ def reset_query: () -> void
68
+
67
69
  def reset_hostname: (String hostname, ?connection: Connection, ?reset_candidates: bool) -> void
68
70
 
69
71
  def close_or_resolve: () -> void
data/sig/resolver.rbs CHANGED
@@ -8,14 +8,17 @@ module HTTPX
8
8
  | { "name" => String, "TTL" => Numeric, "data" => String }
9
9
 
10
10
  RESOLVE_TIMEOUT: Array[Integer]
11
+ MAX_CACHE_SIZE: Integer
11
12
 
12
13
  self.@lookup_mutex: Thread::Mutex
14
+ self.@hostnames: Array[String]
13
15
  self.@lookups: Hash[String, Array[dns_result]]
14
16
  self.@identifier_mutex: Thread::Mutex
15
17
  self.@identifier: Integer
16
18
  self.@hosts_resolver: Resolv::Hosts
19
+ self.@supported_ip_families: Array[Integer]
17
20
 
18
- type dns_decoding_response = [:ok, Array[dns_result]] | [:decode_error, Resolv::DNS::DecodeError] | [:dns_error, Integer] | Symbol
21
+ type dns_decoding_response = [:ok, Array[dns_result]] | [:decode_error, Resolv::DNS::DecodeError] | [:retriable_error | :dns_error, Integer] | Symbol
19
22
 
20
23
  def self?.nolookup_resolve: (String hostname) -> Array[Entry]?
21
24
 
@@ -33,7 +36,7 @@ module HTTPX
33
36
 
34
37
  def self?.cached_lookup_evict: (String hostname, _ToS ip) -> void
35
38
 
36
- def self?.lookup: (String hostname, Hash[String, Array[dns_result]] lookups, Numeric ttl) -> Array[Entry]?
39
+ def self?.lookup: (String hostname, Hash[String, Array[dns_result]] lookups, Array[String] hostnames, Numeric ttl) -> Array[Entry]?
37
40
 
38
41
  def self?.generate_id: () -> Integer
39
42
 
@@ -41,8 +44,14 @@ module HTTPX
41
44
 
42
45
  def self?.decode_dns_answer: (String) -> dns_decoding_response
43
46
 
44
- def self?.lookup_synchronize: [U] () { (Hash[String, Array[dns_result]] lookups) -> U } -> U
47
+ private
48
+
49
+ def self?.lookup_synchronize: [U] () { (Hash[String, Array[dns_result]] lookups, Array[String] hostnames) -> U } -> U
45
50
 
46
51
  def self?.id_synchronize: () { () -> void } -> void
52
+
53
+ def in_ractor?: () -> bool
54
+
55
+ def find_supported_ip_families: () -> Array[Integer]
47
56
  end
48
57
  end
data/sig/response.rbs CHANGED
@@ -63,6 +63,7 @@ module HTTPX
63
63
  @header_value: String?
64
64
  @mime_type: String?
65
65
  @charset: String?
66
+ @initialized: bool
66
67
 
67
68
  def mime_type: () -> String?
68
69
 
@@ -71,6 +72,8 @@ module HTTPX
71
72
  private
72
73
 
73
74
  def initialize: (String? header_value) -> void
75
+
76
+ def load: () -> void
74
77
  end
75
78
 
76
79
  class ErrorResponse
data/sig/session.rbs CHANGED
@@ -55,10 +55,8 @@ module HTTPX
55
55
  def set_request_callbacks: (Request request) -> void
56
56
 
57
57
  def build_requests: (verb, uri, request_params) -> Array[Request]
58
- | (Array[[verb, uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
59
- | (Array[[verb, uri]], request_params) -> Array[Request]
60
- | (verb, _Each[[uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
61
- | (verb, _Each[uri], request_params) -> Array[Request]
58
+ | (Array[[verb, uri] | [verb, uri, request_params]], ?request_params) -> Array[Request]
59
+ | (verb, _Each[[uri] | [uri, request_params]], request_params) -> Array[Request]
62
60
 
63
61
  def do_init_connection: (Connection connection, Selector selector) -> void
64
62
 
@@ -76,7 +74,7 @@ module HTTPX
76
74
 
77
75
  def find_resolver_for: (Connection connection, Selector selector) -> resolver
78
76
 
79
- def coalesce_connections: (Connection conn1, Connection conn2, Selector selector, bool from_pool) -> bool
77
+ def coalesce_connections: (Connection conn1, Connection conn2, Selector selector, bool from_pool) -> void
80
78
 
81
79
  def get_current_selector: () -> Selector?
82
80
  | () { () -> Selector } -> Selector
@@ -7,8 +7,6 @@ module HTTPX
7
7
  def read: (?int? length, ?string? output) -> String?
8
8
  end
9
9
 
10
- MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
11
-
12
10
  type multipart_value = string | Pathname | File | Tempfile | _Reader
13
11
 
14
12
  type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
@@ -22,6 +20,10 @@ module HTTPX
22
20
 
23
21
  def self?.multipart?: (form_nested_value | multipart_nested_value form_data) -> bool
24
22
 
23
+ def self?.multipart_value?: (multipart_nested_value value) -> bool
24
+
25
+ def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?_KeyNormalizer transcoder) { (String, ?untyped) -> U } -> U
26
+
25
27
  class Encoder
26
28
  @boundary: String
27
29
  @part_index: Integer
data/sig/transcoder.rbs CHANGED
@@ -3,8 +3,12 @@ module HTTPX
3
3
 
4
4
  type body_encoder = (Transcoder::_Encoder & _ToS) | (Transcoder::_Encoder & _Reader) | (Transcoder::_Encoder & _Each[String])
5
5
 
6
+ interface _KeyNormalizer
7
+ def normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?_KeyNormalizer transcoder) { (String, ?untyped) -> U } -> U
8
+ end
9
+
6
10
  module Transcoder
7
- def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?(^(untyped value) -> bool | nil) cond) { (String, ?untyped) -> U } -> U
11
+ def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?_KeyNormalizer transcoder) { (String, ?untyped) -> U } -> U
8
12
 
9
13
  def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth) -> void
10
14
 
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.6.3
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
@@ -159,6 +159,7 @@ extra_rdoc_files:
159
159
  - doc/release_notes/1_6_1.md
160
160
  - doc/release_notes/1_6_2.md
161
161
  - doc/release_notes/1_6_3.md
162
+ - doc/release_notes/1_7_0.md
162
163
  files:
163
164
  - LICENSE.txt
164
165
  - README.md
@@ -290,6 +291,7 @@ files:
290
291
  - doc/release_notes/1_6_1.md
291
292
  - doc/release_notes/1_6_2.md
292
293
  - doc/release_notes/1_6_3.md
294
+ - doc/release_notes/1_7_0.md
293
295
  - lib/httpx.rb
294
296
  - lib/httpx/adapters/datadog.rb
295
297
  - lib/httpx/adapters/faraday.rb