Class: NetHttp2::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/net-http2/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, options = {}) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
20
# File 'lib/net-http2/client.rb', line 13

def initialize(url, options={})
  @uri         = URI.parse(url)
  @ssl_context = add_npn_to_context(options[:ssl_context] || OpenSSL::SSL::SSLContext.new)

  @is_ssl = (@uri.scheme == 'https')

  init_vars
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



11
12
13
# File 'lib/net-http2/client.rb', line 11

def uri
  @uri
end

Instance Method Details

#call(method, path, options = {}) ⇒ Object



22
23
24
25
26
# File 'lib/net-http2/client.rb', line 22

def call(method, path, options={})
  request = prepare_request(method, path, options)
  ensure_open
  new_stream.call_with request
end

#call_async(request) ⇒ Object



28
29
30
31
# File 'lib/net-http2/client.rb', line 28

def call_async(request)
  ensure_open
  new_stream.async_call_with request
end

#closeObject



41
42
43
44
# File 'lib/net-http2/client.rb', line 41

def close
  exit_thread(@socket_thread)
  init_vars
end

#prepare_request(method, path, options = {}) ⇒ Object



33
34
35
# File 'lib/net-http2/client.rb', line 33

def prepare_request(method, path, options={})
  NetHttp2::Request.new(method, @uri, path, options)
end

#ssl?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/net-http2/client.rb', line 37

def ssl?
  @is_ssl
end