Sha256: 09f3fca6e0c43589a2961ca87ee8603295729f310fa65ca696bfd3257b156e15

Contents?: true

Size: 1.16 KB

Versions: 16

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2018-2024, by Samuel Williams.
# Copyright, 2019, by Brian Morearty.

require_relative 'http10'
require_relative 'http11'

require_relative 'http2'

module Async
	module HTTP
		module Protocol
			# A server that supports both HTTP1.0 and HTTP1.1 semantics by detecting the version of the request.
			module HTTPS
				HANDLERS = {
					"h2" => HTTP2,
					"http/1.1" => HTTP11,
					"http/1.0" => HTTP10,
					nil => HTTP11,
				}
				
				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
				
				def self.client(peer)
					protocol_for(peer).client(peer)
				end
				
				def self.server(peer)
					protocol_for(peer).server(peer)
				end
				
				# Supported Application Layer Protocol Negotiation names:
				def self.names
					HANDLERS.keys.compact
				end
			end
		end
	end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
async-http-0.76.0 lib/async/http/protocol/https.rb
async-http-0.75.0 lib/async/http/protocol/https.rb
async-http-0.74.0 lib/async/http/protocol/https.rb
async-http-0.73.0 lib/async/http/protocol/https.rb
async-http-0.72.0 lib/async/http/protocol/https.rb
async-http-0.71.0 lib/async/http/protocol/https.rb
async-http-0.70.0 lib/async/http/protocol/https.rb
async-http-0.69.0 lib/async/http/protocol/https.rb
async-http-0.68.0 lib/async/http/protocol/https.rb
async-http-0.67.1 lib/async/http/protocol/https.rb
async-http-0.67.0 lib/async/http/protocol/https.rb
async-http-0.66.2 lib/async/http/protocol/https.rb
async-http-0.66.1 lib/async/http/protocol/https.rb
async-http-0.66.0 lib/async/http/protocol/https.rb
async-http-0.65.1 lib/async/http/protocol/https.rb
async-http-0.65.0 lib/async/http/protocol/https.rb