Class: Protocol::HTTP::Body::Head

Inherits:
Readable
  • Object
show all
Defined in:
lib/protocol/http/body/head.rb

Overview

Represents a body suitable for HEAD requests, in other words, a body that is empty and has a known length.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Readable

#as_json, #buffered, #call, #close, #discard, #each, #finish, #join, #read, #rewind, #rewindable?, #stream?, #to_json

Constructor Details

#initialize(length) ⇒ Head

Initialize the head body with the given length.



25
26
27
# File 'lib/protocol/http/body/head.rb', line 25

def initialize(length)
	@length = length
end

Class Method Details

.for(body) ⇒ Object

Create a head body for the given body, capturing it’s length and then closing it.



14
15
16
17
18
19
20
# File 'lib/protocol/http/body/head.rb', line 14

def self.for(body)
	head = self.new(body.length)
	
	body.close
	
	return head
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/protocol/http/body/head.rb', line 30

def empty?
	true
end

#lengthObject



40
41
42
# File 'lib/protocol/http/body/head.rb', line 40

def length
	@length
end

#ready?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/protocol/http/body/head.rb', line 35

def ready?
	true
end