Class: NetHttp2::Client
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Callbacks
#callback_events, #emit, #on
Constructor Details
#initialize(url, options = {}) ⇒ Client
Returns a new instance of Client.
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/net-http2/client.rb', line 17
def initialize(url, options={})
@uri = URI.parse(url)
@connect_timeout = options[:connect_timeout] || 60
@ssl_context = add_npn_to_context(options[:ssl_context] || OpenSSL::SSL::SSLContext.new)
PROXY_SETTINGS_KEYS.each do |key|
instance_variable_set("@#{key}", options[key]) if options[key]
end
@is_ssl = (@uri.scheme == 'https')
@mutex = Mutex.new
init_vars
end
|
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
15
16
17
|
# File 'lib/net-http2/client.rb', line 15
def uri
@uri
end
|
Instance Method Details
#call(method, path, options = {}) ⇒ Object
32
33
34
35
36
|
# File 'lib/net-http2/client.rb', line 32
def call(method, path, options={})
request = prepare_request(method, path, options)
ensure_open
new_stream.call_with request
end
|
#call_async(request) ⇒ Object
38
39
40
41
42
|
# File 'lib/net-http2/client.rb', line 38
def call_async(request)
ensure_open
stream = new_monitored_stream_for request
stream.async_call_with request
end
|
#close ⇒ Object
52
53
54
55
|
# File 'lib/net-http2/client.rb', line 52
def close
exit_thread(@socket_thread)
init_vars
end
|
#join ⇒ Object
57
58
59
60
61
|
# File 'lib/net-http2/client.rb', line 57
def join
while !@streams.empty? do
sleep 0.05
end
end
|
#prepare_request(method, path, options = {}) ⇒ Object
44
45
46
|
# File 'lib/net-http2/client.rb', line 44
def prepare_request(method, path, options={})
NetHttp2::Request.new(method, @uri, path, options)
end
|
#ssl? ⇒ Boolean
48
49
50
|
# File 'lib/net-http2/client.rb', line 48
def ssl?
@is_ssl
end
|