global
def stream_response(&block)
def stream_response(&block) size = 0 yielded = false block_result = block.call do |chunk| if chunk.bytesize.positive? || size.positive? yielded = true size += chunk.bytesize request.on_data.call(chunk, size, self) end end request.on_data.call(+'', 0, self) unless yielded block_result end