class Protocol::Rack::Input
def read_next
def read_next if @body # User's may forget to call #close... if chunk = @body.read # If the user reads exactly the content length, we close the stream automatically: # https://github.com/socketry/async-http/issues/183 if @body.empty? @body.close @closed = true end return chunk else unless @closed # So if we are at the end of the stream, we close it automatically: @body.close @closed = true end return nil end elsif @closed raise IOError, "Stream is not readable, input has been closed!" end end