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

#inspect, #peer, #remote_address, #remote_address=

Constructor Details

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

Returns a new instance of Request.



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

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, self.public_method(:write_interim_response))
end

Class Method Details

.read(connection) ⇒ Object



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

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

Instance Method Details

#connectionObject



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

def connection
	@connection
end

#hijack!Object



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

def hijack!
	@connection.hijack!
end

#hijack?Boolean

Returns:

  • (Boolean)


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

def hijack?
	true
end

#write_interim_response(status, headers = nil) ⇒ Object



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

def write_interim_response(status, headers = nil)
	@connection.write_interim_response(@version, status, headers)
end