lib/http/protocol/http1/connection.rb in http-protocol-0.11.0 vs lib/http/protocol/http1/connection.rb in http-protocol-0.12.0

- old
+ new

@@ -88,12 +88,10 @@ @stream.write("#{method} #{path} #{version}\r\n") @stream.write("host: #{authority}\r\n") write_headers(headers) write_persistent_header(version) - - @stream.flush end def write_response(version, status, headers, body = nil, head = false) @stream.write("#{version} #{status}\r\n") @@ -185,18 +183,20 @@ return chunk end def write_empty_body(body) @stream.write("content-length: 0\r\n\r\n") + @stream.flush if body body.close if body.respond_to?(:close) end end def write_fixed_length_body(body, length, head) @stream.write("content-length: #{length}\r\n\r\n") + @stream.flush if head body.close if body.respond_to?(:close) return @@ -220,10 +220,11 @@ end end def write_chunked_body(body, head) @stream.write("transfer-encoding: chunked\r\n\r\n") + @stream.flush if head body.close if body.respond_to?(:close) return @@ -237,26 +238,28 @@ @stream.write(CRLF) @stream.flush end @stream.write("0\r\n\r\n") + @stream.flush end def write_body_and_close(body, head) # We can't be persistent because we don't know the data length: @persistent = false @stream.write("\r\n") + @stream.flush if head body.close if body.respond_to?(:close) else body.each do |chunk| @stream.write(chunk) @stream.flush end end - @stream.stream.close_write + @stream.io.close_write end def write_body(body, chunked = true, head = false) if body.nil? or body.empty? write_empty_body(body)