File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed
Expand file tree Collapse file tree 3 files changed +23
-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 33## Unreleased
44
55 - Introduce ` Protocol::HTTP::Middleware.load ` method for loading middleware applications from files.
6+ - Prevent ` ZLib::BufError ` when deflating empty chunks by skipping deflation for empty chunks.
67
78## v0.58.1
89
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