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 =
{
	"http/1.0" => HTTP10,
	"http/1.1" => HTTP11,
	"h2" => HTTP2,
	nil => HTTP11,
}

Class Method Summary collapse

Class Method Details

.client(stream) ⇒ Object



57
58
59
# File 'lib/async/http/protocol/https.rb', line 57

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

.protocol_for(stream) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/async/http/protocol/https.rb', line 44

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

.server(stream) ⇒ Object



61
62
63
# File 'lib/async/http/protocol/https.rb', line 61

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