File tree Expand file tree Collapse file tree 3 files changed +26
-9
lines changed
Expand file tree Collapse file tree 3 files changed +26
-9
lines changed Original file line number Diff line number Diff line change @@ -113,15 +113,19 @@ def read
113113 return if @stream . finished?
114114
115115 # The stream might have been closed while waiting for the chunk to come in.
116- if chunk = super
117- @input_length += chunk . bytesize
118-
119- chunk = @stream . deflate ( chunk , Zlib ::SYNC_FLUSH )
120-
121- @output_length += chunk . bytesize
122-
123- return chunk
124- elsif !@stream . closed?
116+ while chunk = super
117+ unless chunk . empty?
118+ @input_length += chunk . bytesize
119+
120+ chunk = @stream . deflate ( chunk , Zlib ::SYNC_FLUSH )
121+
122+ @output_length += chunk . bytesize
123+
124+ return chunk
125+ end
126+ end
127+
128+ if !@stream . closed?
125129 chunk = @stream . finish
126130
127131 @output_length += chunk . bytesize
Original file line number Diff line number Diff line change 11# Releases
22
3+ ## Unreleased
4+
5+ - Prevent ` ZLib::BufError ` when deflating empty chunks by skipping deflation for empty chunks.
6+
37## v0.55.0
48
59 - ** Breaking** : Move ` Protocol::HTTP::Header::QuotedString ` to ` Protocol::HTTP::QuotedString ` for better reusability.
Original file line number Diff line number Diff line change 7272 )
7373 end
7474 end
75+
76+ with "empty chunks" do
77+ let ( :body ) { Protocol ::HTTP ::Body ::Buffered . new ( [ "" , "bar" , "" ] ) }
78+
79+ it "can read empty chunks" do
80+ expect ( decompressed_body . read ) . to be == "bar"
81+ expect ( decompressed_body . read ) . to be == nil
82+ end
83+ end
7584end
You can’t perform that action at this time.
0 commit comments