lib/kcar/response.rb in kcar-0.5.0 vs lib/kcar/response.rb in kcar-0.6.0

- old
+ new

@@ -5,12 +5,10 @@ # class Kcar::Response attr_accessor :sock, :hdr, :unchunk, :buf, :parser # :stopdoc: - LAST_CHUNK = "0\r\n" - CRLF = "\r\n" Parser = Kcar::Parser # :startdoc: # By default we readpartial at most 16K off a socket at once READ_SIZE = 0x4000 @@ -89,25 +87,25 @@ begin @parser.filter_body(dst, @buf) and break size = dst.size if size > 0 yield("#{size.to_s(16)}\r\n") - yield(dst << CRLF) + yield(dst << "\r\n".freeze) end break if @parser.body_eof? end while @buf << @sock.readpartial(READ_SIZE, dst) - yield LAST_CHUNK + yield "0\r\n".freeze until @parser.trailers(@hdr, @buf) @buf << @sock.readpartial(READ_SIZE, dst) end # since Rack does not provide a way to explicitly send trailers # in the response, we'll just yield a stringified version to our # server and pretend it's part of the body. trailers = @parser.extract_trailers(@hdr) - yield(trailers.map! { |k,v| "#{k}: #{v}\r\n" }.join << CRLF) + yield(trailers.map! { |k,v| "#{k}: #{v}\r\n" }.join << "\r\n".freeze) end def each_until_eof yield @buf unless @buf.empty? # easy, just read and write everything until EOFError