lib/httpx/response.rb in httpx-0.4.1 vs lib/httpx/response.rb in httpx-0.5.0

- old
+ new

@@ -109,11 +109,11 @@ begin unless @state == :idle rewind while (chunk = @buffer.read(@window_size)) - yield(chunk) + yield(chunk.force_encoding(@encoding)) end end ensure close end @@ -127,11 +127,11 @@ return content.force_encoding(@encoding) rescue ArgumentError # ex: unknown encoding name - utf return content end end - "" + "".b ensure close end alias_method :to_str, :to_s @@ -176,18 +176,18 @@ def transition case @state when :idle if @length > @threshold_size @state = :buffer - @buffer = Tempfile.new("httpx", encoding: @encoding, mode: File::RDWR) + @buffer = Tempfile.new("httpx", encoding: Encoding::BINARY, mode: File::RDWR) else @state = :memory @buffer = StringIO.new("".b, File::RDWR) end when :memory if @length > @threshold_size aux = @buffer - @buffer = Tempfile.new("httpx", encoding: @encoding, mode: File::RDWR) + @buffer = Tempfile.new("httpx", encoding: Encoding::BINARY, mode: File::RDWR) aux.rewind ::IO.copy_stream(aux, @buffer) # (this looks like a bug from Ruby < 2.3 @buffer.pos = aux.pos ################## ########################################