lib/httpx/parser/http1.rb in httpx-0.5.0 vs lib/httpx/parser/http1.rb in httpx-0.5.1
- old
+ new
@@ -65,11 +65,12 @@
@http_version = version.split(".").map(&:to_i)
@status_code = code.to_i
raise(Error, "wrong status code (#{@status_code})") unless (100..599).cover?(@status_code)
- @buffer.slice!(0, idx + 1)
+ # @buffer.slice!(0, idx + 1)
+ @buffer = @buffer.byteslice((idx + 1)..-1)
nextstate(:headers)
end
def parse_headers
headers = @headers
@@ -114,10 +115,11 @@
if @buffer.respond_to?(:each)
@buffer.each do |chunk|
@observer.on_data(chunk)
end
elsif @content_length
- data = @buffer.slice!(0, @content_length)
+ data = @buffer.byteslice(0, @content_length)
+ @buffer = @buffer.byteslice(@content_length..-1) || "".b
@content_length -= data.bytesize
@observer.on_data(data)
data.clear
else
@observer.on_data(@buffer)