httpx 0.17.0 → 0.18.3

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/doc/release_notes/0_18_0.md +69 -0
  4. data/doc/release_notes/0_18_1.md +12 -0
  5. data/doc/release_notes/0_18_2.md +10 -0
  6. data/doc/release_notes/0_18_3.md +7 -0
  7. data/lib/httpx/adapters/datadog.rb +1 -1
  8. data/lib/httpx/adapters/faraday.rb +5 -3
  9. data/lib/httpx/adapters/webmock.rb +7 -1
  10. data/lib/httpx/altsvc.rb +2 -2
  11. data/lib/httpx/chainable.rb +3 -3
  12. data/lib/httpx/connection/http1.rb +8 -5
  13. data/lib/httpx/connection/http2.rb +22 -7
  14. data/lib/httpx/connection.rb +70 -71
  15. data/lib/httpx/domain_name.rb +1 -1
  16. data/lib/httpx/extensions.rb +50 -4
  17. data/lib/httpx/io/ssl.rb +5 -1
  18. data/lib/httpx/io/tls.rb +7 -7
  19. data/lib/httpx/loggable.rb +5 -5
  20. data/lib/httpx/options.rb +7 -7
  21. data/lib/httpx/plugins/aws_sdk_authentication.rb +42 -18
  22. data/lib/httpx/plugins/aws_sigv4.rb +9 -11
  23. data/lib/httpx/plugins/compression.rb +5 -3
  24. data/lib/httpx/plugins/cookies/jar.rb +1 -1
  25. data/lib/httpx/plugins/expect.rb +7 -3
  26. data/lib/httpx/plugins/grpc/message.rb +2 -2
  27. data/lib/httpx/plugins/grpc.rb +3 -3
  28. data/lib/httpx/plugins/internal_telemetry.rb +8 -8
  29. data/lib/httpx/plugins/multipart.rb +2 -2
  30. data/lib/httpx/plugins/response_cache/store.rb +55 -0
  31. data/lib/httpx/plugins/response_cache.rb +88 -0
  32. data/lib/httpx/plugins/retries.rb +36 -14
  33. data/lib/httpx/plugins/stream.rb +1 -1
  34. data/lib/httpx/pool.rb +39 -13
  35. data/lib/httpx/request.rb +7 -7
  36. data/lib/httpx/resolver/https.rb +5 -7
  37. data/lib/httpx/resolver/native.rb +4 -2
  38. data/lib/httpx/resolver/system.rb +2 -0
  39. data/lib/httpx/resolver.rb +2 -2
  40. data/lib/httpx/response.rb +23 -14
  41. data/lib/httpx/selector.rb +12 -17
  42. data/lib/httpx/session.rb +7 -2
  43. data/lib/httpx/session2.rb +1 -1
  44. data/lib/httpx/timers.rb +84 -0
  45. data/lib/httpx/transcoder/body.rb +2 -1
  46. data/lib/httpx/transcoder/form.rb +1 -1
  47. data/lib/httpx/transcoder/json.rb +1 -1
  48. data/lib/httpx/utils.rb +8 -0
  49. data/lib/httpx/version.rb +1 -1
  50. data/lib/httpx.rb +1 -0
  51. data/sig/chainable.rbs +1 -0
  52. data/sig/connection/http1.rbs +5 -0
  53. data/sig/connection/http2.rbs +3 -0
  54. data/sig/connection.rbs +12 -6
  55. data/sig/plugins/aws_sdk_authentication.rbs +22 -4
  56. data/sig/plugins/response_cache.rbs +35 -0
  57. data/sig/plugins/retries.rbs +3 -0
  58. data/sig/pool.rbs +6 -0
  59. data/sig/resolver/native.rbs +3 -4
  60. data/sig/resolver/system.rbs +2 -0
  61. data/sig/response.rbs +3 -2
  62. data/sig/timers.rbs +32 -0
  63. data/sig/utils.rbs +4 -0
  64. metadata +17 -17
data/lib/httpx.rb CHANGED
@@ -13,6 +13,7 @@ require "httpx/callbacks"
13
13
  require "httpx/loggable"
14
14
  require "httpx/registry"
15
15
  require "httpx/transcoder"
16
+ require "httpx/timers"
16
17
  require "httpx/pool"
17
18
  require "httpx/headers"
18
19
  require "httpx/request"
data/sig/chainable.rbs CHANGED
@@ -32,6 +32,7 @@ module HTTPX
32
32
  | (:stream, ?options) -> Plugins::sessionStream
33
33
  | (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
34
34
  | (:grpc, ?options) -> Plugins::grpcSession
35
+ | (:response_cache, ?options) -> Plugins::sessionResponseCache
35
36
  | (Symbol | Module, ?options) { (Class) -> void } -> Session
36
37
  | (Symbol | Module, ?options) -> Session
37
38
 
@@ -15,6 +15,11 @@ module HTTPX
15
15
  @max_requests: Integer
16
16
  @parser: Parser::HTTP1
17
17
  @buffer: Buffer
18
+ @version: [Integer, Integer]
19
+ @handshake_completed: bool
20
+ @pipelining: bool
21
+
22
+ @request: Request?
18
23
 
19
24
  def interests: () -> io_interests?
20
25
 
@@ -92,5 +92,8 @@ module HTTPX
92
92
 
93
93
  class Error < ::HTTPX::Error
94
94
  end
95
+
96
+ class GoawayError < Error
97
+ end
95
98
  end
96
99
  end
data/sig/connection.rbs CHANGED
@@ -25,7 +25,15 @@ module HTTPX
25
25
  attr_reader state: Symbol
26
26
  attr_reader pending: Array[Request]
27
27
  attr_reader options: Options
28
- attr_writer timers: untyped # Timers::Timer
28
+ attr_writer timers: Timers
29
+
30
+ @origins: Array[URI::Generic]
31
+ @window_size: Integer
32
+ @read_buffer: Buffer
33
+ @write_buffer: Buffer
34
+ @inflight: Integer
35
+ @keep_alive_timeout: Numeric?
36
+ @total_timeout: Numeric?
29
37
 
30
38
  def addresses: () -> Array[ipaddr]?
31
39
 
@@ -62,6 +70,7 @@ module HTTPX
62
70
 
63
71
  def timeout: () -> Numeric?
64
72
 
73
+ def deactivate: () -> void
65
74
  private
66
75
 
67
76
  def initialize: (String, URI::Generic, options) -> untyped
@@ -76,6 +85,8 @@ module HTTPX
76
85
 
77
86
  def parser: () -> _Parser
78
87
 
88
+ def send_request_to_parser: (Request request) -> void
89
+
79
90
  def build_parser: () -> _Parser
80
91
  | (String) -> _Parser
81
92
 
@@ -83,15 +94,10 @@ module HTTPX
83
94
 
84
95
  def transition: (Symbol) -> void
85
96
 
86
- def handle_response: () -> void
87
-
88
97
  def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
89
98
 
90
99
  def handle_error: (StandardError) -> void
91
100
 
92
- def total_timeout: () -> untyped?
93
- # def total_timeout: () -> Timers::Timer?
94
- #
95
101
  def purge_after_closed: () -> void
96
102
  end
97
103
  end
@@ -1,25 +1,43 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module AwsSdkAuthentication
4
+ class Configuration
5
+ attr_reader profile: String?
6
+
7
+ private
8
+
9
+ def initialize: (String? profile) -> void
10
+ end
11
+
4
12
  class Credentials
13
+ @aws_credentials: untyped
14
+
5
15
  include _SigV4Credentials
6
16
 
7
17
  private
8
-
18
+
9
19
  def initialize: (untyped aws_credentials) -> untyped
10
20
  end
11
21
 
22
+ interface _AwsSdkOptions
23
+ def aws_profile: () -> String?
24
+ end
25
+
12
26
  def self.load_dependencies: (singleton(Session)) -> void
13
27
 
14
28
  def self.configure: (singleton(Session)) -> void
15
29
 
16
- def self.extra_options: (Options) -> (Options)
30
+ def self.extra_options: (Options) -> (Options & _AwsSdkOptions)
31
+
32
+ def self.credentials: (String? profile) -> Credentials
33
+
34
+ def self.region: (String? profile) -> String
17
35
 
18
36
  module InstanceMethods
19
- def aws_sdk_authentication: (**untyped) -> instance
37
+ def aws_sdk_authentication: (?credentials: Credentials, ?region: String, **untyped) -> instance
20
38
  end
21
39
  end
22
40
 
23
- type sessionAwsSdkAuthentication = Session & AwsSdkAuthentication::InstanceMethods
41
+ type sessionAwsSdkAuthentication = awsSigV4Session & AwsSdkAuthentication::InstanceMethods
24
42
  end
25
43
  end
@@ -0,0 +1,35 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module ResponseCache
4
+ CACHEABLE_VERBS: Array[Symbol]
5
+
6
+ def self?.cacheable_request?: (Request request) -> bool
7
+ def self?.cacheable_response?: (response response) -> bool
8
+ def self?.cached_response?: (response response) -> bool
9
+
10
+ class Store
11
+ @store: Hash[URI::Generic, Response]
12
+
13
+ def lookup: (URI::Generic uri) -> Response?
14
+
15
+ def cached?: (URI::Generic uri) -> bool
16
+
17
+ def cache: (URI::Generic uri, Response response) -> void
18
+
19
+ def prepare: (Request request) -> void
20
+ end
21
+
22
+ module InstanceMethods
23
+ @response_cache: Store
24
+
25
+ def clear_response_cache: () -> void
26
+ end
27
+
28
+ module ResponseMethods
29
+ def copy_from_cached: (Response other) -> void
30
+ end
31
+ end
32
+
33
+ type sessionResponseCache = Session & ResponseCache::InstanceMethods
34
+ end
35
+ end
@@ -4,6 +4,7 @@ module HTTPX
4
4
  MAX_RETRIES: Integer
5
5
  IDEMPOTENT_METHODS: Array[verb]
6
6
  RETRYABLE_ERRORS: Array[singleton(StandardError)]
7
+ DEFAULT_JITTER: ^(Numeric) -> Numeric
7
8
 
8
9
  interface _RetryCallback
9
10
  def call: (response) -> bool?
@@ -12,6 +13,8 @@ module HTTPX
12
13
  interface _RetriesOptions
13
14
  def retry_after: () -> Numeric?
14
15
 
16
+ def retry_jitter: () -> ^(Numeric) -> Numeric
17
+
15
18
  def max_retries: () -> Integer?
16
19
 
17
20
  def retry_change_requests: () -> boolish
data/sig/pool.rbs CHANGED
@@ -10,6 +10,8 @@ module HTTPX
10
10
 
11
11
  def find_connection: (generic_uri, Options) -> Connection?
12
12
 
13
+ def deactivate: (*Array[Connection]) -> void
14
+
13
15
  private
14
16
 
15
17
  def initialize: () -> untyped
@@ -26,6 +28,10 @@ module HTTPX
26
28
 
27
29
  def unregister_connection: (Connection) -> void
28
30
 
31
+ def select_connection: (resolver | Connection connection) -> void
32
+
33
+ def deselect_connection: (resolver | Connection connection) -> void
34
+
29
35
  def coalesce_connections: (Connection, Connection) -> void
30
36
 
31
37
  def next_timeout: () -> Numeric?
@@ -5,8 +5,6 @@ module HTTPX
5
5
  include ResolverMixin
6
6
  include _ToIO
7
7
 
8
- type state = :idle | :open | :closed
9
-
10
8
  DEFAULTS: Hash[Symbol, untyped]
11
9
  DNS_PORT: Integer
12
10
 
@@ -21,7 +19,8 @@ module HTTPX
21
19
  @queries: Hash[String, Connection]
22
20
  @read_buffer: String
23
21
  @write_buffer: Buffer
24
- @state: state
22
+
23
+ attr_reader state: Symbol
25
24
 
26
25
  def closed?: () -> bool
27
26
 
@@ -58,7 +57,7 @@ module HTTPX
58
57
 
59
58
  def build_socket: () -> void
60
59
 
61
- def transition: (state nextstate) -> void
60
+ def transition: (Symbol nextstate) -> void
62
61
 
63
62
  def handle_error: (NativeResolveError | StandardError) -> void
64
63
  end
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  RESOLV_ERRORS: Array[singleton(StandardError)] # ResolvError
7
7
 
8
+ attr_reader state: Symbol
9
+
8
10
  def closed?: () -> true
9
11
 
10
12
  def empty?: () -> true
data/sig/response.rbs CHANGED
@@ -1,6 +1,8 @@
1
1
  module HTTPX
2
2
  interface _Response
3
- def raise_for_status: () -> void
3
+ def raise_for_status: () -> self
4
+
5
+ def error: () -> StandardError?
4
6
  end
5
7
 
6
8
  class Response
@@ -89,7 +91,6 @@ module HTTPX
89
91
  @options: Options
90
92
 
91
93
  attr_reader request: Request
92
- attr_reader error: Exception
93
94
 
94
95
  def status: () -> (Integer | _ToS)
95
96
 
data/sig/timers.rbs ADDED
@@ -0,0 +1,32 @@
1
+ module HTTPX
2
+ class Timers
3
+ @interval: Array[Interval]
4
+
5
+ def after: (Numeric interval_in_secs) { () -> void } -> void
6
+
7
+ def wait_interval: () -> Numeric?
8
+
9
+ def fire: (?StandardError error) -> void
10
+
11
+ def cancel: () -> void
12
+
13
+ private
14
+
15
+ def initialize: () -> void
16
+
17
+ class Interval
18
+ include Comparable
19
+
20
+ attr_reader interval: Numeric
21
+
22
+ def to_f: () -> Float
23
+
24
+ def <<: (^() -> void) -> void
25
+
26
+ def elapse: (Numeric elapsed) -> Numeric
27
+ private
28
+
29
+ def initialize: (Numeric interval) -> void
30
+ end
31
+ end
32
+ end
data/sig/utils.rbs CHANGED
@@ -4,6 +4,10 @@ module HTTPX
4
4
 
5
5
  def self?.parse_retry_after: (String) -> Numeric
6
6
 
7
+ def self?.now: () -> Numeric
8
+
9
+ def self?.elapsed_time: (Numeric monotonic_time) -> Numeric
10
+
7
11
  def self?.to_uri: (generic_uri uri) -> URI::Generic
8
12
  end
9
13
  end
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: 0.17.0
4
+ version: 0.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-31 00:00:00.000000000 Z
11
+ date: 2021-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.1
27
- - !ruby/object:Gem::Dependency
28
- name: timers
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  description: A client library for making HTTP requests from Ruby.
42
28
  email:
43
29
  - cardoso_tiago@hotmail.com
@@ -76,6 +62,10 @@ extra_rdoc_files:
76
62
  - doc/release_notes/0_16_0.md
77
63
  - doc/release_notes/0_16_1.md
78
64
  - doc/release_notes/0_17_0.md
65
+ - doc/release_notes/0_18_0.md
66
+ - doc/release_notes/0_18_1.md
67
+ - doc/release_notes/0_18_2.md
68
+ - doc/release_notes/0_18_3.md
79
69
  - doc/release_notes/0_1_0.md
80
70
  - doc/release_notes/0_2_0.md
81
71
  - doc/release_notes/0_2_1.md
@@ -131,6 +121,10 @@ files:
131
121
  - doc/release_notes/0_16_0.md
132
122
  - doc/release_notes/0_16_1.md
133
123
  - doc/release_notes/0_17_0.md
124
+ - doc/release_notes/0_18_0.md
125
+ - doc/release_notes/0_18_1.md
126
+ - doc/release_notes/0_18_2.md
127
+ - doc/release_notes/0_18_3.md
134
128
  - doc/release_notes/0_1_0.md
135
129
  - doc/release_notes/0_2_0.md
136
130
  - doc/release_notes/0_2_1.md
@@ -214,6 +208,8 @@ files:
214
208
  - lib/httpx/plugins/proxy/ssh.rb
215
209
  - lib/httpx/plugins/push_promise.rb
216
210
  - lib/httpx/plugins/rate_limiter.rb
211
+ - lib/httpx/plugins/response_cache.rb
212
+ - lib/httpx/plugins/response_cache/store.rb
217
213
  - lib/httpx/plugins/retries.rb
218
214
  - lib/httpx/plugins/stream.rb
219
215
  - lib/httpx/plugins/upgrade.rb
@@ -232,6 +228,7 @@ files:
232
228
  - lib/httpx/selector.rb
233
229
  - lib/httpx/session.rb
234
230
  - lib/httpx/session2.rb
231
+ - lib/httpx/timers.rb
235
232
  - lib/httpx/transcoder.rb
236
233
  - lib/httpx/transcoder/body.rb
237
234
  - lib/httpx/transcoder/chunker.rb
@@ -278,6 +275,7 @@ files:
278
275
  - sig/plugins/proxy/ssh.rbs
279
276
  - sig/plugins/push_promise.rbs
280
277
  - sig/plugins/rate_limiter.rbs
278
+ - sig/plugins/response_cache.rbs
281
279
  - sig/plugins/retries.rbs
282
280
  - sig/plugins/stream.rbs
283
281
  - sig/plugins/upgrade.rbs
@@ -292,6 +290,7 @@ files:
292
290
  - sig/response.rbs
293
291
  - sig/selector.rbs
294
292
  - sig/session.rbs
293
+ - sig/timers.rbs
295
294
  - sig/transcoder.rbs
296
295
  - sig/transcoder/body.rbs
297
296
  - sig/transcoder/chunker.rbs
@@ -307,6 +306,7 @@ metadata:
307
306
  documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
308
307
  source_code_uri: https://gitlab.com/honeyryderchuck/httpx
309
308
  homepage_uri: https://honeyryderchuck.gitlab.io/httpx/
309
+ rubygems_mfa_required: 'true'
310
310
  post_install_message:
311
311
  rdoc_options: []
312
312
  require_paths:
@@ -322,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
322
  - !ruby/object:Gem::Version
323
323
  version: '0'
324
324
  requirements: []
325
- rubygems_version: 3.2.15
325
+ rubygems_version: 3.2.22
326
326
  signing_key:
327
327
  specification_version: 4
328
328
  summary: HTTPX, to the future, and beyond