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.



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

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.



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

def reason
  @reason
end

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



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

attr :reason

Class Method Details

.read(connection, request) ⇒ Object



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

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



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

def connection
	@connection
end

#hijack!Object



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

def hijack!
	@connection.hijack!
end

#hijack?Boolean

Returns:

  • (Boolean)


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

def hijack?
	@body.nil?
end