httpx 1.4.3 → 1.5.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_4_4.md +14 -0
  3. data/doc/release_notes/1_5_0.md +126 -0
  4. data/lib/httpx/adapters/datadog.rb +24 -3
  5. data/lib/httpx/adapters/webmock.rb +3 -0
  6. data/lib/httpx/buffer.rb +16 -5
  7. data/lib/httpx/connection/http1.rb +8 -9
  8. data/lib/httpx/connection/http2.rb +48 -24
  9. data/lib/httpx/connection.rb +40 -20
  10. data/lib/httpx/errors.rb +2 -11
  11. data/lib/httpx/headers.rb +24 -23
  12. data/lib/httpx/io/ssl.rb +8 -4
  13. data/lib/httpx/io/tcp.rb +9 -7
  14. data/lib/httpx/io/unix.rb +1 -1
  15. data/lib/httpx/loggable.rb +13 -1
  16. data/lib/httpx/options.rb +63 -48
  17. data/lib/httpx/parser/http1.rb +1 -1
  18. data/lib/httpx/plugins/aws_sigv4.rb +1 -0
  19. data/lib/httpx/plugins/callbacks.rb +19 -6
  20. data/lib/httpx/plugins/circuit_breaker.rb +4 -3
  21. data/lib/httpx/plugins/cookies/jar.rb +0 -2
  22. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +7 -4
  23. data/lib/httpx/plugins/cookies.rb +4 -4
  24. data/lib/httpx/plugins/follow_redirects.rb +4 -2
  25. data/lib/httpx/plugins/grpc/call.rb +1 -1
  26. data/lib/httpx/plugins/h2c.rb +7 -1
  27. data/lib/httpx/plugins/persistent.rb +22 -1
  28. data/lib/httpx/plugins/proxy/http.rb +3 -1
  29. data/lib/httpx/plugins/query.rb +35 -0
  30. data/lib/httpx/plugins/response_cache/file_store.rb +115 -15
  31. data/lib/httpx/plugins/response_cache/store.rb +7 -67
  32. data/lib/httpx/plugins/response_cache.rb +179 -29
  33. data/lib/httpx/plugins/retries.rb +27 -15
  34. data/lib/httpx/plugins/stream.rb +46 -20
  35. data/lib/httpx/plugins/stream_bidi.rb +315 -0
  36. data/lib/httpx/pool.rb +58 -5
  37. data/lib/httpx/request/body.rb +1 -1
  38. data/lib/httpx/request.rb +21 -5
  39. data/lib/httpx/resolver/https.rb +10 -4
  40. data/lib/httpx/resolver/native.rb +13 -13
  41. data/lib/httpx/resolver/resolver.rb +4 -0
  42. data/lib/httpx/resolver/system.rb +37 -14
  43. data/lib/httpx/resolver.rb +2 -2
  44. data/lib/httpx/response/body.rb +10 -21
  45. data/lib/httpx/response/buffer.rb +36 -12
  46. data/lib/httpx/response.rb +11 -1
  47. data/lib/httpx/selector.rb +16 -12
  48. data/lib/httpx/session.rb +80 -23
  49. data/lib/httpx/timers.rb +24 -16
  50. data/lib/httpx/transcoder/multipart/decoder.rb +4 -2
  51. data/lib/httpx/transcoder/multipart/encoder.rb +2 -1
  52. data/lib/httpx/version.rb +1 -1
  53. data/sig/buffer.rbs +1 -1
  54. data/sig/chainable.rbs +5 -2
  55. data/sig/connection/http2.rbs +11 -2
  56. data/sig/connection.rbs +4 -4
  57. data/sig/errors.rbs +0 -3
  58. data/sig/headers.rbs +15 -10
  59. data/sig/httpx.rbs +5 -1
  60. data/sig/io/tcp.rbs +6 -0
  61. data/sig/loggable.rbs +2 -0
  62. data/sig/options.rbs +7 -1
  63. data/sig/plugins/cookies/cookie.rbs +1 -3
  64. data/sig/plugins/cookies/jar.rbs +4 -4
  65. data/sig/plugins/cookies/set_cookie_parser.rbs +22 -0
  66. data/sig/plugins/cookies.rbs +2 -0
  67. data/sig/plugins/h2c.rbs +4 -0
  68. data/sig/plugins/proxy/http.rbs +3 -0
  69. data/sig/plugins/proxy.rbs +4 -0
  70. data/sig/plugins/response_cache/file_store.rbs +19 -0
  71. data/sig/plugins/response_cache/store.rbs +13 -0
  72. data/sig/plugins/response_cache.rbs +41 -19
  73. data/sig/plugins/retries.rbs +4 -3
  74. data/sig/plugins/stream.rbs +8 -1
  75. data/sig/plugins/stream_bidi.rbs +68 -0
  76. data/sig/plugins/upgrade/h2.rbs +9 -0
  77. data/sig/plugins/upgrade.rbs +5 -0
  78. data/sig/pool.rbs +5 -0
  79. data/sig/punycode.rbs +5 -0
  80. data/sig/request.rbs +7 -0
  81. data/sig/resolver/https.rbs +3 -2
  82. data/sig/resolver/native.rbs +1 -2
  83. data/sig/resolver/resolver.rbs +11 -3
  84. data/sig/resolver/system.rbs +19 -2
  85. data/sig/resolver.rbs +11 -7
  86. data/sig/response/body.rbs +3 -4
  87. data/sig/response/buffer.rbs +2 -3
  88. data/sig/response.rbs +2 -2
  89. data/sig/selector.rbs +20 -10
  90. data/sig/session.rbs +14 -6
  91. data/sig/timers.rbs +5 -7
  92. data/sig/transcoder/multipart.rbs +4 -3
  93. metadata +14 -5
  94. data/lib/httpx/session2.rb +0 -23
  95. data/lib/httpx/transcoder/utils/inflater.rb +0 -21
  96. data/sig/transcoder/utils/inflater.rbs +0 -12
data/sig/session.rbs CHANGED
@@ -6,7 +6,6 @@ module HTTPX
6
6
  EMPTY_HASH: Hash[untyped, untyped]
7
7
 
8
8
  @options: Options
9
- @responses: Hash[Request, response]
10
9
 
11
10
  # returns the HTTPX::Pool object which manages the networking required to
12
11
  # perform requests.
@@ -14,8 +13,7 @@ module HTTPX
14
13
 
15
14
  @persistent: bool
16
15
  @wrapped: bool
17
-
18
- def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
16
+ @closing: bool
19
17
 
20
18
  def wrap: () { (instance) -> void } -> void
21
19
 
@@ -44,8 +42,6 @@ module HTTPX
44
42
 
45
43
  def deactivate: (Selector selector) -> void
46
44
 
47
- def on_response: (Request, response) -> void
48
-
49
45
  def on_promise: (untyped, untyped) -> void
50
46
 
51
47
  def fetch_response: (Request request, Selector selector, Options options) -> response?
@@ -86,7 +82,19 @@ module HTTPX
86
82
  def selector_store: () -> Hash[instance, Selector]
87
83
 
88
84
  attr_reader self.default_options: Options
85
+ self.@plugins: Array[Module]
86
+
87
+ def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
88
+
89
+
90
+ INSTANCES: Hash[Session, Session]
91
+
92
+ def self.after_fork: () -> void
93
+
94
+ module ForkTracker
95
+ def _fork: () -> void
96
+ end
89
97
  end
90
98
 
91
- OriginalSession: singleton(Session)
99
+ S: singleton(Session)
92
100
  end
data/sig/timers.rbs CHANGED
@@ -14,18 +14,16 @@ module HTTPX
14
14
 
15
15
  def initialize: () -> void
16
16
 
17
+ private
18
+
19
+ def drop_elapsed!: (?Numeric elapsed_time) -> void
20
+
17
21
  class Interval
18
22
  include Comparable
19
23
 
20
24
  attr_reader interval: Numeric
21
25
 
22
26
  @callbacks: Array[callback]
23
- @on_empty: callback?
24
-
25
-
26
- def on_empty: () { () -> void } -> void
27
-
28
- def cancel: () -> void
29
27
 
30
28
  def to_f: () -> Float
31
29
 
@@ -35,7 +33,7 @@ module HTTPX
35
33
 
36
34
  def elapse: (Numeric elapsed) -> Numeric
37
35
 
38
- def elapsed?: () -> bool
36
+ def elapsed?: (?Numeric elapsed_time) -> bool
39
37
 
40
38
  def no_callbacks?: () -> bool
41
39
 
@@ -40,11 +40,11 @@ module HTTPX
40
40
 
41
41
  def initialize: (Enumerable[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
42
42
 
43
- def header_part: (string key, String content_type, String? filename) -> StringIO
43
+ def header_part: (String key, String content_type, String? filename) -> StringIO
44
44
 
45
- def read_chunks: (String buffer, ?int? length) -> void
45
+ def read_chunks: (String buffer, ?Integer? length) -> void
46
46
 
47
- def read_from_part: (?int? max_length) -> String?
47
+ def read_from_part: (?Integer? max_length) -> String?
48
48
  end
49
49
 
50
50
  class Decoder
@@ -60,6 +60,7 @@ module HTTPX
60
60
  @parts: Hash[String, untyped]
61
61
  @boundary: String
62
62
  @intermediate_boundary: String
63
+ @current: String?
63
64
 
64
65
  def call: (Response response, *untyped) -> Hash[String, untyped]
65
66
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-25 00:00:00.000000000 Z
10
+ date: 2025-05-16 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: http-2
@@ -152,6 +152,8 @@ extra_rdoc_files:
152
152
  - doc/release_notes/1_4_1.md
153
153
  - doc/release_notes/1_4_2.md
154
154
  - doc/release_notes/1_4_3.md
155
+ - doc/release_notes/1_4_4.md
156
+ - doc/release_notes/1_5_0.md
155
157
  files:
156
158
  - LICENSE.txt
157
159
  - README.md
@@ -276,6 +278,8 @@ files:
276
278
  - doc/release_notes/1_4_1.md
277
279
  - doc/release_notes/1_4_2.md
278
280
  - doc/release_notes/1_4_3.md
281
+ - doc/release_notes/1_4_4.md
282
+ - doc/release_notes/1_5_0.md
279
283
  - lib/httpx.rb
280
284
  - lib/httpx/adapters/datadog.rb
281
285
  - lib/httpx/adapters/faraday.rb
@@ -337,6 +341,7 @@ files:
337
341
  - lib/httpx/plugins/proxy/socks5.rb
338
342
  - lib/httpx/plugins/proxy/ssh.rb
339
343
  - lib/httpx/plugins/push_promise.rb
344
+ - lib/httpx/plugins/query.rb
340
345
  - lib/httpx/plugins/rate_limiter.rb
341
346
  - lib/httpx/plugins/response_cache.rb
342
347
  - lib/httpx/plugins/response_cache/file_store.rb
@@ -344,6 +349,7 @@ files:
344
349
  - lib/httpx/plugins/retries.rb
345
350
  - lib/httpx/plugins/ssrf_filter.rb
346
351
  - lib/httpx/plugins/stream.rb
352
+ - lib/httpx/plugins/stream_bidi.rb
347
353
  - lib/httpx/plugins/upgrade.rb
348
354
  - lib/httpx/plugins/upgrade/h2.rb
349
355
  - lib/httpx/plugins/webdav.rb
@@ -364,7 +370,6 @@ files:
364
370
  - lib/httpx/response/buffer.rb
365
371
  - lib/httpx/selector.rb
366
372
  - lib/httpx/session.rb
367
- - lib/httpx/session2.rb
368
373
  - lib/httpx/session_extensions.rb
369
374
  - lib/httpx/timers.rb
370
375
  - lib/httpx/transcoder.rb
@@ -381,7 +386,6 @@ files:
381
386
  - lib/httpx/transcoder/multipart/part.rb
382
387
  - lib/httpx/transcoder/utils/body_reader.rb
383
388
  - lib/httpx/transcoder/utils/deflater.rb
384
- - lib/httpx/transcoder/utils/inflater.rb
385
389
  - lib/httpx/utils.rb
386
390
  - lib/httpx/version.rb
387
391
  - sig/altsvc.rbs
@@ -419,6 +423,7 @@ files:
419
423
  - sig/plugins/cookies.rbs
420
424
  - sig/plugins/cookies/cookie.rbs
421
425
  - sig/plugins/cookies/jar.rbs
426
+ - sig/plugins/cookies/set_cookie_parser.rbs
422
427
  - sig/plugins/digest_auth.rbs
423
428
  - sig/plugins/expect.rbs
424
429
  - sig/plugins/follow_redirects.rbs
@@ -439,13 +444,18 @@ files:
439
444
  - sig/plugins/query.rbs
440
445
  - sig/plugins/rate_limiter.rbs
441
446
  - sig/plugins/response_cache.rbs
447
+ - sig/plugins/response_cache/file_store.rbs
448
+ - sig/plugins/response_cache/store.rbs
442
449
  - sig/plugins/retries.rbs
443
450
  - sig/plugins/ssrf_filter.rbs
444
451
  - sig/plugins/stream.rbs
452
+ - sig/plugins/stream_bidi.rbs
445
453
  - sig/plugins/upgrade.rbs
454
+ - sig/plugins/upgrade/h2.rbs
446
455
  - sig/plugins/webdav.rbs
447
456
  - sig/plugins/xml.rbs
448
457
  - sig/pool.rbs
458
+ - sig/punycode.rbs
449
459
  - sig/request.rbs
450
460
  - sig/request/body.rbs
451
461
  - sig/resolver.rbs
@@ -470,7 +480,6 @@ files:
470
480
  - sig/transcoder/multipart.rbs
471
481
  - sig/transcoder/utils/body_reader.rbs
472
482
  - sig/transcoder/utils/deflater.rbs
473
- - sig/transcoder/utils/inflater.rbs
474
483
  - sig/utils.rbs
475
484
  homepage: https://gitlab.com/os85/httpx
476
485
  licenses:
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "session"
4
- module HTTPX
5
- class Session
6
- def initialize(options = EMPTY, &blk)
7
- @options = self.class.default_options.merge(options)
8
- @responses = {}
9
- @persistent = @options.persistent
10
- wrap(&blk) if blk
11
- end
12
-
13
- def wrap
14
- begin
15
- prev_persistent = @persistent
16
- @persistent = true
17
- yield self
18
- ensure
19
- @persistent = prev_persistent
20
- end
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module HTTPX
4
- module Transcoder
5
- class Inflater
6
- def initialize(bytesize)
7
- @bytesize = bytesize
8
- end
9
-
10
- def call(chunk)
11
- buffer = @inflater.inflate(chunk)
12
- @bytesize -= chunk.bytesize
13
- if @bytesize <= 0
14
- buffer << @inflater.finish
15
- @inflater.close
16
- end
17
- buffer
18
- end
19
- end
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- module HTTPX
2
- module Transcoder
3
- class Inflater
4
- @inflater: Zlib::Inflate
5
- @bytesize: Integer
6
-
7
- def initialize: (Integer | Float bytesize) -> void
8
-
9
- def call: (String chunk) -> String
10
- end
11
- end
12
- end