Class: Async::HTTP::Protocol::HTTP1::Request

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

Constant Summary collapse

UPGRADE =
'upgrade'

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

#peer, #remote_address, #remote_address=

Constructor Details

#initialize(connection, authority, method, path, version, headers, body) ⇒ Request

Returns a new instance of Request.



38
39
40
41
42
43
44
45
# File 'lib/async/http/protocol/http1/request.rb', line 38

def initialize(connection, authority, method, path, version, headers, body)
  @connection = connection
  
  # HTTP/1 requests with an upgrade header (which can contain zero or more values) are extracted into the protocol field of the request, and we expect a response to select one of those protocols with a status code of 101 Switching Protocols.
  protocol = headers.delete('upgrade')
  
  super(nil, authority, method, path, version, headers, body, protocol)
end

Class Method Details

.read(connection) ⇒ Object



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

def self.read(connection)
  if parts = connection.read_request
    self.new(connection, *parts)
  end
end

Instance Method Details

#connectionObject



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

def connection
  @connection
end

#hijack!Object



55
56
57
# File 'lib/async/http/protocol/http1/request.rb', line 55

def hijack!
  @connection.hijack!
end

#hijack?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/async/http/protocol/http1/request.rb', line 51

def hijack?
  true
end