-
Notifications
You must be signed in to change notification settings - Fork 300
Open
Description
There is a difference in StringIO#read behaviour between ruby 3.3.x and 3.4.x.
The difference is illustrated by this:
Ruby 3.3.7:
irb(main):001> RUBY_VERSION
=> "3.3.7"
irb(main):002> binary_io = StringIO.new("\x00".b)
=> #<StringIO:0x00007f50541b8518>
irb(main):003> buf = ''
=> ""
irb(main):004> buf.encoding
=> #<Encoding:UTF-8>
irb(main):005> binary_io.read(1, buf)
=> "\x00"
irb(main):006> buf.encoding
=> #<Encoding:ASCII-8BIT>Ruby 3.4.0:
irb(main):001> RUBY_VERSION
=> "3.4.0"
irb(main):002> binary_io = StringIO.new("\x00".b)
=> #<StringIO:0x000071c808fafab8>
irb(main):003> buf = ''
=> ""
irb(main):004> buf.encoding
=> #<Encoding:UTF-8>
irb(main):005> binary_io.read(1, buf)
=> "\u0000"
irb(main):006> buf.encoding
=> #<Encoding:UTF-8>I experience that this new beahaviour affects httpclient when using StringIO as body on PUT requests:
httpclient/lib/httpclient/http.rb
Line 580 in d57cc6d
| n = io.read([rest, @chunk_size].min, buf) |
This may very well also affect other http methods. I have not tried.
The workaround is not to upgrade ruby to 3.4.x
Metadata
Metadata
Assignees
Labels
No labels