Class: NetHttp2::Client
- Inherits:
-
Object
- Object
- NetHttp2::Client
- Defined in:
- lib/net-http2/client.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #call(method, path, options = {}) ⇒ Object
- #call_async(request) ⇒ Object
- #close ⇒ Object
-
#initialize(url, options = {}) ⇒ Client
constructor
A new instance of Client.
- #join ⇒ Object
- #prepare_request(method, path, options = {}) ⇒ Object
- #ssl? ⇒ Boolean
Constructor Details
#initialize(url, options = {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/net-http2/client.rb', line 13 def initialize(url, ={}) @uri = URI.parse(url) @connect_timeout = [:connect_timeout] || 60 @ssl_context = add_npn_to_context([:ssl_context] || OpenSSL::SSL::SSLContext.new) @is_ssl = (@uri.scheme == 'https') @mutex = Mutex.new init_vars end |
Instance Attribute Details
#uri ⇒ Object (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
24 25 26 27 28 |
# File 'lib/net-http2/client.rb', line 24 def call(method, path, ={}) request = prepare_request(method, path, ) ensure_open new_stream.call_with request end |
#call_async(request) ⇒ Object
30 31 32 33 34 |
# File 'lib/net-http2/client.rb', line 30 def call_async(request) ensure_open stream = new_monitored_stream_for request stream.async_call_with request end |
#close ⇒ Object
44 45 46 47 |
# File 'lib/net-http2/client.rb', line 44 def close exit_thread(@socket_thread) init_vars end |
#join ⇒ Object
49 50 51 52 53 |
# File 'lib/net-http2/client.rb', line 49 def join while !@streams.empty? do sleep 0.05 end end |
#prepare_request(method, path, options = {}) ⇒ Object
36 37 38 |
# File 'lib/net-http2/client.rb', line 36 def prepare_request(method, path, ={}) NetHttp2::Request.new(method, @uri, path, ) end |
#ssl? ⇒ Boolean
40 41 42 |
# File 'lib/net-http2/client.rb', line 40 def ssl? @is_ssl end |