multipart: initialize @bytesize in the initializer (for object shape opt)

This commit is contained in:
HoneyryderChuck 2025-03-19 16:59:25 +00:00
parent eb8c18ccda
commit 6d4266d4a4
2 changed files with 3 additions and 2 deletions

View File

@ -11,6 +11,7 @@ module HTTPX
@buffer = "".b
@form = form
@bytesize = 0
@parts = to_parts(form)
end
@ -42,6 +43,7 @@ module HTTPX
aux << [key, val]
end
@form = form
@bytesize = 0
@parts = to_parts(form)
@part_index = 0
end
@ -49,7 +51,6 @@ module HTTPX
private
def to_parts(form)
@bytesize = 0
params = form.each_with_object([]) do |(key, val), aux|
Transcoder.normalize_keys(key, val, MULTIPART_VALUE_COND) do |k, v|
next if v.nil?

View File

@ -24,7 +24,7 @@ module HTTPX
@form: Enumerable[[Symbol | string, Object & multipart_nested_value]]
@parts: Array[Object & _Reader]
def bytesize: () -> Integer
attr_reader bytesize: Integer
def content_type: () -> String