lib/protocol/http1/body/chunked.rb in protocol-http1-0.14.0 vs lib/protocol/http1/body/chunked.rb in protocol-http1-0.14.1

- old
+ new

@@ -54,10 +54,11 @@ # Follows the procedure outlined in https://tools.ietf.org/html/rfc7230#section-4.1.3 def read return nil if @finished + # It is possible this line contains chunk extension, so we use `to_i` to only consider the initial integral part: length = read_line.to_i(16) if length == 0 @finished = true @@ -82,15 +83,19 @@ "\#<#{self.class} #{@length} bytes read in #{@count} chunks>" end private - def read_line + def read_line? @stream.gets(CRLF, chomp: true) end + def read_line + read_line? or raise EOFError + end + def read_trailer - while line = read_line + while line = read_line? # Empty line indicates end of trailer: break if line.empty? if match = line.match(HEADER) @headers.add(match[1], match[2])