Class: Hypertube::Utils::Http2ConnectionData
- Inherits:
-
Object
- Object
- Hypertube::Utils::Http2ConnectionData
- Defined in:
- lib/hypertube-ruby-sdk/utils/http2_connection_data.rb
Constant Summary collapse
- DEFAULT_CONNECT_TIMEOUT_SECONDS =
60
Instance Attribute Summary collapse
-
#hostname ⇒ Object
Returns the value of attribute hostname.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #add_header(key, value) ⇒ Object
- #add_headers(headers) ⇒ Object
- #connection_type ⇒ Object
- #headers ⇒ Object
-
#initialize(hostname, timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) ⇒ Http2ConnectionData
constructor
A new instance of Http2ConnectionData.
- #serialize_connection_data ⇒ Object
- #to_canonical_key ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hostname, timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) ⇒ Http2ConnectionData
Returns a new instance of Http2ConnectionData.
10 11 12 13 14 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 10 def initialize(hostname, timeout = DEFAULT_CONNECT_TIMEOUT_SECONDS) @hostname = hostname @timeout = timeout @headers = {} end |
Instance Attribute Details
#hostname ⇒ Object
Returns the value of attribute hostname.
8 9 10 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 8 def hostname @hostname end |
#timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 8 def timeout @timeout end |
Instance Method Details
#add_header(key, value) ⇒ Object
24 25 26 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 24 def add_header(key, value) @headers[key.to_s] = value.to_s end |
#add_headers(headers) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 28 def add_headers(headers) return if headers.nil? headers.each do |key, value| add_header(key, value) end end |
#connection_type ⇒ Object
16 17 18 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 16 def connection_type Hypertube::Utils::ConnectionType::HTTP2 end |
#headers ⇒ Object
20 21 22 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 20 def headers @headers.dup end |
#serialize_connection_data ⇒ Object
36 37 38 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 36 def serialize_connection_data [connection_type, 0, 0, 0, 0, 0, 0] end |
#to_canonical_key ⇒ Object
44 45 46 47 48 49 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 44 def to_canonical_key headers_for_key = serialize_headers_for_key return to_s if headers_for_key.empty? "#{to_s}|h:#{headers_for_key}" end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/hypertube-ruby-sdk/utils/http2_connection_data.rb', line 40 def to_s "http2|#{@hostname}" end |