Module: Async::HTTP::Protocol::HTTPS

Defined in:
lib/async/http/protocol/https.rb

Overview

A server that supports both HTTP1.0 and HTTP1.1 semantics by detecting the version of the request.

Constant Summary collapse

HANDLERS =
{
	"h2" => HTTP2,
	"http/1.1" => HTTP11,
	"http/1.0" => HTTP10,
	nil => HTTP11,
}

Class Method Summary collapse

Class Method Details

.client(peer) ⇒ Object



37
38
39
# File 'lib/async/http/protocol/https.rb', line 37

def self.client(peer)
	protocol_for(peer).client(peer)
end

.namesObject

Supported Application Layer Protocol Negotiation names:



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

def self.names
	HANDLERS.keys.compact
end

.protocol_for(peer) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/async/http/protocol/https.rb', line 24

def self.protocol_for(peer)
	# alpn_protocol is only available if openssl v1.0.2+
	name = peer.alpn_protocol
	
	Console.logger.debug(self) {"Negotiating protocol #{name.inspect}..."}
	
	if protocol = HANDLERS[name]
		return protocol
	else
		raise ArgumentError, "Could not determine protocol for connection (#{name.inspect})."
	end
end

.server(peer) ⇒ Object



41
42
43
# File 'lib/async/http/protocol/https.rb', line 41

def self.server(peer)
	protocol_for(peer).server(peer)
end