lib/httpx/response.rb in httpx-0.23.3 vs lib/httpx/response.rb in httpx-0.23.4

- old
+ new

@@ -105,10 +105,12 @@ decoder = transcoder.decode(self) raise Error, "no decoder available for \"#{transcoder}\"" unless decoder + @body.rewind + decoder.call(self, *args) end def no_data? @status < 200 || # informational response @@ -150,13 +152,16 @@ end def read(*args) return unless @buffer - rewind + unless @reader + rewind + @reader = @buffer + end - @buffer.read(*args) + @reader.read(*args) end def bytesize @length end @@ -247,16 +252,19 @@ "@state=#{@state} " \ "@length=#{@length}>" end # :nocov: - private - def rewind return unless @buffer + # in case there's some reading going on + @reader = nil + @buffer.rewind end + + private def transition case @state when :idle if @length > @threshold_size