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(uri, 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(uri, options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/net-http2/client.rb', line 11 def initialize(uri, ={}) @uri = URI.parse(uri) @ssl_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.
9 10 11 |
# File 'lib/net-http2/client.rb', line 9 def uri @uri end |
Instance Method Details
#async_delete(path, headers = {}, options = {}, &block) ⇒ Object
57 58 59 60 |
# File 'lib/net-http2/client.rb', line 57 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
42 43 44 45 |
# File 'lib/net-http2/client.rb', line 42 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
47 48 49 50 |
# File 'lib/net-http2/client.rb', line 47 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
52 53 54 55 |
# File 'lib/net-http2/client.rb', line 52 def async_put(path, body, headers={}, ={}, &block) request = NetHttp2::Request::Put.new(@uri, path, body, headers, ) async_call_with request, &block end |
#close ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/net-http2/client.rb', line 66 def close exit_thread(@socket_thread) @h2 = nil @pipe_r = nil @pipe_w = nil @socket_thread = nil end |
#delete(path, headers = {}, options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/net-http2/client.rb', line 37 def delete(path, headers={}, ={}) request = NetHttp2::Request::Delete.new(@uri, path, headers, ) call_with request end |
#get(path, headers = {}, options = {}) ⇒ Object
22 23 24 25 |
# File 'lib/net-http2/client.rb', line 22 def get(path, headers={}, ={}) request = NetHttp2::Request::Get.new(@uri, path, headers, ) call_with request end |
#post(path, body, headers = {}, options = {}) ⇒ Object
27 28 29 30 |
# File 'lib/net-http2/client.rb', line 27 def post(path, body, headers={}, ={}) request = NetHttp2::Request::Post.new(@uri, path, body, headers, ) call_with request end |
#put(path, body, headers = {}, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/net-http2/client.rb', line 32 def put(path, body, headers={}, ={}) request = NetHttp2::Request::Put.new(@uri, path, body, headers, ) call_with request end |
#ssl? ⇒ Boolean
62 63 64 |
# File 'lib/net-http2/client.rb', line 62 def ssl? @is_ssl end |