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
- #async_delete(path, headers = {}, options = {}, &block) ⇒ Object
- #async_get(path, headers = {}, options = {}, &block) ⇒ Object
- #async_post(path, body, headers = {}, options = {}, &block) ⇒ Object
- #async_put(path, body, headers = {}, options = {}, &block) ⇒ Object
- #close ⇒ Object
- #delete(path, headers = {}, options = {}) ⇒ Object
- #get(path, headers = {}, options = {}) ⇒ Object
-
#initialize(url, options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, body, headers = {}, options = {}) ⇒ Object
- #put(path, body, headers = {}, 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) @ssl_context = add_npn_to_context([:ssl_context] || OpenSSL::SSL::SSLContext.new) @is_ssl = (@uri.scheme == 'https') @pipe_r, @pipe_w = Socket.pair(:UNIX, :STREAM, 0) @socket_thread = nil @mutex = Mutex.new 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
#async_delete(path, headers = {}, options = {}, &block) ⇒ Object
59 60 61 62 |
# File 'lib/net-http2/client.rb', line 59 def async_delete(path, headers={}, ={}, &block) request = NetHttp2::Request::Delete.new(@uri, path, headers, ) async_call_with request, &block end |
#async_get(path, headers = {}, options = {}, &block) ⇒ Object
44 45 46 47 |
# File 'lib/net-http2/client.rb', line 44 def async_get(path, headers={}, ={}, &block) request = NetHttp2::Request::Get.new(@uri, path, headers, ) async_call_with request, &block end |
#async_post(path, body, headers = {}, options = {}, &block) ⇒ Object
49 50 51 52 |
# File 'lib/net-http2/client.rb', line 49 def async_post(path, body, headers={}, ={}, &block) request = NetHttp2::Request::Post.new(@uri, path, body, headers, ) async_call_with request, &block end |
#async_put(path, body, headers = {}, options = {}, &block) ⇒ Object
54 55 56 57 |
# File 'lib/net-http2/client.rb', line 54 def async_put(path, body, headers={}, ={}, &block) request = NetHttp2::Request::Put.new(@uri, path, body, headers, ) async_call_with request, &block end |
#close ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/net-http2/client.rb', line 68 def close exit_thread(@socket_thread) @h2 = nil @pipe_r = nil @pipe_w = nil @socket_thread = nil end |
#delete(path, headers = {}, options = {}) ⇒ Object
39 40 41 42 |
# File 'lib/net-http2/client.rb', line 39 def delete(path, headers={}, ={}) request = NetHttp2::Request::Delete.new(@uri, path, headers, ) call_with request end |
#get(path, headers = {}, options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/net-http2/client.rb', line 24 def get(path, headers={}, ={}) request = NetHttp2::Request::Get.new(@uri, path, headers, ) call_with request end |
#post(path, body, headers = {}, options = {}) ⇒ Object
29 30 31 32 |
# File 'lib/net-http2/client.rb', line 29 def post(path, body, headers={}, ={}) request = NetHttp2::Request::Post.new(@uri, path, body, headers, ) call_with request end |
#put(path, body, headers = {}, options = {}) ⇒ Object
34 35 36 37 |
# File 'lib/net-http2/client.rb', line 34 def put(path, body, headers={}, ={}) request = NetHttp2::Request::Put.new(@uri, path, body, headers, ) call_with request end |
#ssl? ⇒ Boolean
64 65 66 |
# File 'lib/net-http2/client.rb', line 64 def ssl? @is_ssl end |