lib/async/http/protocol/http11.rb in async-http-0.14.0 vs lib/async/http/protocol/http11.rb in async-http-0.15.0

- old
+ new

@@ -70,11 +70,11 @@ status, headers, body = yield request write_response(request.version, status, headers, body) - request.close + request.finish unless keep_alive?(request.headers) and keep_alive?(headers) @keep_alive = false break @@ -175,55 +175,9 @@ buffer = String.new body.each{|chunk| buffer << chunk} @stream.write("Content-Length: #{buffer.bytesize}\r\n\r\n") @stream.write(buffer) - end - end - - class ChunkedBody - def initialize(protocol) - @protocol = protocol - @closed = false - end - - def closed? - @closed - end - - def each - return if @closed - - while true - size = @protocol.read_line.to_i(16) - - if size == 0 - @protocol.read_line - - @closed = true - - return - end - - chunk = @protocol.stream.read(size) - @protocol.read_line # Consume the trailing CRLF - - yield chunk - end - end - - def read - buffer = Async::IO::BinaryString.new - - self.each do |chunk| - buffer << chunk - end - - return buffer - end - - def close - self.each {} end end def read_body(headers) if headers['transfer-encoding'] == 'chunked'