diff --git a/lib/httpx/plugins/multipart/encoder.rb b/lib/httpx/plugins/multipart/encoder.rb index 4864e3a9..fca237d5 100644 --- a/lib/httpx/plugins/multipart/encoder.rb +++ b/lib/httpx/plugins/multipart/encoder.rb @@ -15,8 +15,14 @@ module HTTPX::Plugins "multipart/form-data; boundary=#{@boundary}" end - def bytesize - @parts.map(&:size).sum + if RUBY_VERSION > "2.3" + def bytesize + @parts.map(&:size).sum + end + else + def bytesize + @parts.map(&:size).reduce(0, :+) + end end def read(length = nil, outbuf = nil)