Sha256: 4154b02e0640d3a5d38226d25e5552c579efad58bae6982625aa1e5db1ca5ef4

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

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

require_relative 'http2/client'
require_relative 'http2/server'

require 'io/stream/buffered'

module Async
	module HTTP
		module Protocol
			module HTTP2
				VERSION = "HTTP/2"
				
				def self.bidirectional?
					true
				end
				
				def self.trailer?
					true
				end
				
				CLIENT_SETTINGS = {
					::Protocol::HTTP2::Settings::ENABLE_PUSH => 0,
					::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
					::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x800000,
				}
				
				SERVER_SETTINGS = {
					# We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
					::Protocol::HTTP2::Settings::MAXIMUM_CONCURRENT_STREAMS => 128,
					::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
					::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x800000,
					::Protocol::HTTP2::Settings::ENABLE_CONNECT_PROTOCOL => 1,
				}
				
				def self.client(peer, settings = CLIENT_SETTINGS)
					stream = ::IO::Stream::Buffered.wrap(peer)
					client = Client.new(stream)
					
					client.send_connection_preface(settings)
					client.start_connection
					
					return client
				end
				
				def self.server(peer, settings = SERVER_SETTINGS)
					stream = ::IO::Stream::Buffered.wrap(peer)
					server = Server.new(stream)
					
					server.read_connection_preface(settings)
					server.start_connection
					
					return server
				end
				
				def self.names
					["h2"]
				end
			end
		end
	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
async-http-0.66.2 lib/async/http/protocol/http2.rb
async-http-0.66.1 lib/async/http/protocol/http2.rb
async-http-0.66.0 lib/async/http/protocol/http2.rb
async-http-0.65.1 lib/async/http/protocol/http2.rb
async-http-0.65.0 lib/async/http/protocol/http2.rb