Class: Async::HTTP::Protocol::HTTP1::Response

Inherits:
Response
  • Object
show all
Defined in:
lib/async/http/protocol/http1/response.rb

Constant Summary collapse

UPGRADE =
'upgrade'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Response

#peer, #remote_address, #remote_address=

Constructor Details

#initialize(connection, version, status, reason, headers, body) ⇒ Response

Returns a new instance of Response.



29
30
31
32
33
34
35
36
# File 'lib/async/http/protocol/http1/response.rb', line 29

def initialize(connection, version, status, reason, headers, body)
	@connection = connection
	@reason = reason
	
	protocol = headers.delete(UPGRADE)
	
	super(version, status, headers, body, protocol)
end

Instance Attribute Details

#reasonObject (readonly)

Returns the value of attribute reason.



26
27
28
# File 'lib/async/http/protocol/http1/response.rb', line 26

def reason
  @reason
end

#The HTTP response line reason.(HTTPresponselinereason.) ⇒ Object (readonly)



26
# File 'lib/async/http/protocol/http1/response.rb', line 26

attr :reason

Class Method Details

.read(connection, request) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/async/http/protocol/http1/response.rb', line 13

def self.read(connection, request)
	while parts = connection.read_response(request.method)
		response = self.new(connection, *parts)
		
		if response.final?
			return response
		end
	end
end

Instance Method Details

#connectionObject



38
39
40
# File 'lib/async/http/protocol/http1/response.rb', line 38

def connection
	@connection
end

#hijack!Object



46
47
48
# File 'lib/async/http/protocol/http1/response.rb', line 46

def hijack!
	@connection.hijack!
end

#hijack?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/async/http/protocol/http1/response.rb', line 42

def hijack?
	@body.nil?
end