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'

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.

Parameters:

  • reason (String)

    HTTP response line reason, ignored.



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

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

Class Method Details

.read(connection, request) ⇒ Object



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

def self.read(connection, request)
  if parts = connection.read_response(request.method)
    self.new(connection, *parts)
  end
end

Instance Method Details

#connectionObject



30
31
32
# File 'lib/async/http/protocol/http1/response.rb', line 30

def connection
  @connection
end

#hijack!Object



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

def hijack!
  @connection.hijack!
end

#hijack?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/async/http/protocol/http1/response.rb', line 34

def hijack?
  @body.nil?
end