async-http-faraday 0.21.0 → 0.22.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61ec5bb845598b4ed1282944e5ecce5ed41fd0abcac72c4bcdaedcf40b707e89
4
- data.tar.gz: b16fe2a762a49b3cc20cc5c8f7e674d764ef81f1ab1cd8f95fa41f11e5bc057e
3
+ metadata.gz: 91b8ac365195312b4906a8dd4f975cebdea675bda9316e97d7c0ed3186fdb9b0
4
+ data.tar.gz: 526ae0462c42d2be7e5362031a15b68388f6c723278dbcf74c0bde763d16a606
5
5
  SHA512:
6
- metadata.gz: 330032d445badaf1eace0bf580012c573b24a83128c3cb7bd6b479d8710b65558450d892000cbf21aacda704428d28e63dba834f7456c5bc53b7c473f6cd511b
7
- data.tar.gz: 584dd4a49d4af9d088a386f8a6130f199396ba6b93ee79af3a9fc15a6ebfcf66f0cddc7d95cfabb1d9d9acc18291e2128b0e003845e7c6241ec1fc7cc3ba2d2a
6
+ metadata.gz: 5bfad129a4104393375a077cd605aae4955e2adb8497a4a1655438593eb3aed8a56e966e182dc1094759617ecdb722dbe32c19de9e31211526ac705e94ef43d5
7
+ data.tar.gz: f2a3c8b0f1ad783b9ce4cfdbf57d707c5f27d953c7042504fbeaa2feb0fed18e9f6aea0070d162fb9c8301fd4c4a2b1037726fe6dbc8066be46d4bd5c1cff5fa
checksums.yaml.gz.sig CHANGED
Binary file
@@ -32,11 +32,16 @@ module Async
32
32
  #
33
33
  # @parameter body [Interface(:read)] The input body to wrap.
34
34
  # @parameter block_size [Integer] The size of the blocks to read from the body.
35
- def initialize(body, block_size: 4096)
35
+ # @parameter length [Integer | Nil] The length of the body, if known.
36
+ def initialize(body, length = nil, block_size: 4096)
36
37
  @body = body
38
+ @length = length
37
39
  @block_size = block_size
38
40
  end
39
41
 
42
+ # @attribute [Integer | Nil] The total length of the body, or `nil` if the length is unknown.
43
+ attr :length
44
+
40
45
  # Close the body if possible.
41
46
  def close(error = nil)
42
47
  @body.close if @body.respond_to?(:close)
@@ -111,7 +116,7 @@ module Async
111
116
  SocketError
112
117
  ].freeze
113
118
 
114
- # Create a Farady compatible adapter.
119
+ # Create a Faraday compatible adapter.
115
120
  #
116
121
  # @parameter timeout [Integer] The timeout for requests.
117
122
  # @parameter options [Hash] Additional options to pass to the underlying Async::HTTP::Client.
@@ -168,22 +173,27 @@ module Async
168
173
 
169
174
  def perform_request(env)
170
175
  with_client(env) do |endpoint, client|
176
+ if headers = env.request_headers
177
+ headers = ::Protocol::HTTP::Headers[headers]
178
+
179
+ # Use content-length to inform body length if given, but remove the header since it will be
180
+ # set for us later anyway, and not doing so could result in a duplicate content-length headers
181
+ # if capitalization differs
182
+ content_length = headers.delete("content-length")&.to_i
183
+ end
184
+
171
185
  if body = env.body
172
186
  # We need to ensure the body is wrapped in a Readable object so that it can be read in chunks:
173
187
  # Faraday's body only responds to `#read`.
174
188
  if body.is_a?(::Protocol::HTTP::Body::Readable)
175
189
  # Good to go
176
190
  elsif body.respond_to?(:read)
177
- body = BodyReadWrapper.new(body)
191
+ body = BodyReadWrapper.new(body, content_length)
178
192
  else
179
193
  body = ::Protocol::HTTP::Body::Buffered.wrap(body)
180
194
  end
181
195
  end
182
196
 
183
- if headers = env.request_headers
184
- headers = ::Protocol::HTTP::Headers[headers]
185
- end
186
-
187
197
  method = env.method.to_s.upcase
188
198
 
189
199
  request = ::Protocol::HTTP::Request.new(endpoint.scheme, endpoint.authority, method, endpoint.path, nil, headers, body)
@@ -6,7 +6,7 @@
6
6
  module Async
7
7
  module HTTP
8
8
  module Faraday
9
- VERSION = "0.21.0"
9
+ VERSION = "0.22.0"
10
10
  end
11
11
  end
12
12
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http-faraday
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -45,7 +45,7 @@ cert_chain:
45
45
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
46
46
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
47
47
  -----END CERTIFICATE-----
48
- date: 2025-02-15 00:00:00.000000000 Z
48
+ date: 1980-01-02 00:00:00.000000000 Z
49
49
  dependencies:
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: async-http
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  requirements: []
113
- rubygems_version: 3.6.2
113
+ rubygems_version: 3.6.7
114
114
  specification_version: 4
115
115
  summary: Provides an adaptor between async-http and faraday.
116
116
  test_files: []
metadata.gz.sig CHANGED
Binary file