Method: H2::Client#initialize
- Defined in:
- lib/h2/client.rb
#initialize(host: nil, port: 443, url: nil, lazy: true, tls: {}) {|_self| ... } ⇒ H2::Client
create a new h2 client
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/h2/client.rb', line 39 def initialize host: nil, port: 443, url: nil, lazy: true, tls: {} raise ArgumentError if url.nil? && (host.nil? || port.nil?) if url url = URI.parse url unless URI === url @host = url.host @port = url.port @scheme = url.scheme tls = false if 'http' == @scheme else @host = host @port = port @scheme = tls ? 'https' : 'http' end @tls = tls @streams = {} @client = HTTP2::Client.new @read_gate = ReadGate.new init_blocking yield self if block_given? bind_events connect unless lazy end |