lib/protocol/http1/body/remainder.rb in protocol-http1-0.22.0 vs lib/protocol/http1/body/remainder.rb in protocol-http1-0.23.0
- old
+ new
@@ -1,11 +1,11 @@
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2019-2024, by Samuel Williams.
-require 'protocol/http/body/readable'
+require "protocol/http/body/readable"
module Protocol
module HTTP1
module Body
# A body that reads all remaining data from the stream.
@@ -19,15 +19,18 @@
def empty?
@stream.nil?
end
- def close(error = nil)
- if @stream
- # We can't really do anything in this case except close the connection.
- @stream.close_read
+ def discard
+ if stream = @stream
@stream = nil
+ stream.close_read
end
+ end
+
+ def close(error = nil)
+ self.discard
super
end
def read