lib/httpx/response/body.rb in httpx-1.1.2 vs lib/httpx/response/body.rb in httpx-1.1.3
- old
+ new
@@ -39,14 +39,14 @@
# write the response payload +chunk+ into the buffer. Inflates the chunk when required
# and supported.
def write(chunk)
return if @state == :closed
- @inflaters.reverse_each do |inflater|
- chunk = inflater.call(chunk)
- end if @inflaters && !chunk.empty?
+ return 0 if chunk.empty?
+ chunk = decode_chunk(chunk)
+
size = chunk.bytesize
@length += size
transition(:open)
@buffer.write(chunk)
@@ -183,9 +183,17 @@
break unless inflater
@encodings << encoding
inflater
end
+ end
+
+ def decode_chunk(chunk)
+ @inflaters.reverse_each do |inflater|
+ chunk = inflater.call(chunk)
+ end if @inflaters
+
+ chunk
end
def transition(nextstate)
case nextstate
when :open