Class: Protocol::HTTP1::Body::Remainder

Inherits:
HTTP::Body::Readable
  • Object
show all
Defined in:
lib/protocol/http1/body/remainder.rb

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ Remainder

Returns a new instance of Remainder.



27
28
29
# File 'lib/protocol/http1/body/remainder.rb', line 27

def initialize(stream)
	@stream = stream
end

Instance Method Details

#call(stream) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/protocol/http1/body/remainder.rb', line 46

def call(stream)
	self.each do |chunk|
		stream.write(chunk)
	end
	
	stream.flush
end

#close(error = nil) ⇒ Object



35
36
37
38
39
40
# File 'lib/protocol/http1/body/remainder.rb', line 35

def close(error = nil)
	# We can't really do anything in this case except close the connection.
	@stream.close

	super
end

#empty?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/protocol/http1/body/remainder.rb', line 31

def empty?
	@stream.closed?
end

#inspectObject



58
59
60
# File 'lib/protocol/http1/body/remainder.rb', line 58

def inspect
	"\#<#{self.class} #{@stream.closed? ? 'closed' : 'open'}>"
end

#joinObject



54
55
56
# File 'lib/protocol/http1/body/remainder.rb', line 54

def join
	read
end

#readObject



42
43
44
# File 'lib/protocol/http1/body/remainder.rb', line 42

def read
	@stream.read_partial
end