lib/httpx/parser/http1.rb in httpx-1.2.4 vs lib/httpx/parser/http1.rb in httpx-1.2.6

- old
+ new

@@ -73,10 +73,11 @@ def parse_headers headers = @headers buffer = @buffer while (idx = buffer.index("\n")) + # @type var line: String line = buffer.byteslice(0..idx) raise Error, "wrong header format" if line.start_with?("\s", "\t") line.lstrip! buffer = @buffer = buffer.byteslice((idx + 1)..-1) @@ -99,13 +100,15 @@ return end separator_index = line.index(":") raise Error, "wrong header format" unless separator_index + # @type var key: String key = line.byteslice(0..(separator_index - 1)) key.rstrip! # was lstripped previously! + # @type var value: String value = line.byteslice((separator_index + 1)..-1) value.strip! raise Error, "wrong header format" if value.nil? (headers[key.downcase] ||= []) << value @@ -116,9 +119,10 @@ if @buffer.respond_to?(:each) @buffer.each do |chunk| @observer.on_data(chunk) end elsif @content_length + # @type var data: String data = @buffer.byteslice(0, @content_length) @buffer = @buffer.byteslice(@content_length..-1) || "".b @content_length -= data.bytesize @observer.on_data(data) data.clear