Class: GrpcKit::Session::Headers
- Inherits:
-
Object
- Object
- GrpcKit::Session::Headers
- Defined in:
- lib/grpc_kit/session/headers.rb
Constant Summary collapse
- RESERVED_HEADERS =
[ ':path', ':status', ':scheme', 'content-type', 'grpc-message-type', 'grpc-timeout', 'grpc-encoding', 'grpc-message', 'grpc-status', 'grpc-status-details-bin', 'grpc-accept-encoding', 'te', ':method' ].freeze
- METADATA_ACCEPTABLE_HEADER =
%w[:authority user-agent].freeze
Instance Method Summary collapse
- #add(key, val) ⇒ void
- #content_type ⇒ String?
- #grpc_encoding ⇒ String?
- #grpc_status ⇒ String?
- #http_status ⇒ String?
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
- #metadata ⇒ Hash<String,String>
- #path ⇒ String?
- #status_message ⇒ String?
- #timeout ⇒ Time?
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
18 19 20 21 |
# File 'lib/grpc_kit/session/headers.rb', line 18 def initialize @opts = {} @metadata = {} end |
Instance Method Details
#add(key, val) ⇒ void
This method returns an undefined value.
73 74 75 |
# File 'lib/grpc_kit/session/headers.rb', line 73 def add(key, val) @opts[key] = val end |
#content_type ⇒ String?
51 52 53 |
# File 'lib/grpc_kit/session/headers.rb', line 51 def content_type @opts['content-type'] end |
#grpc_encoding ⇒ String?
46 47 48 |
# File 'lib/grpc_kit/session/headers.rb', line 46 def grpc_encoding @opts['grpc-encoding'] end |
#grpc_status ⇒ String?
41 42 43 |
# File 'lib/grpc_kit/session/headers.rb', line 41 def grpc_status @opts['grpc-status'] end |
#http_status ⇒ String?
66 67 68 |
# File 'lib/grpc_kit/session/headers.rb', line 66 def http_status @opts[':status'] end |
#metadata ⇒ Hash<String,String>
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/grpc_kit/session/headers.rb', line 24 def @metadata = if @metadata.empty? @opts.select do |key| !key.start_with?(':', 'grpc-') && !RESERVED_HEADERS.include?(key) end else @metadata end end |
#path ⇒ String?
36 37 38 |
# File 'lib/grpc_kit/session/headers.rb', line 36 def path @opts[':path'] end |
#status_message ⇒ String?
56 57 58 |
# File 'lib/grpc_kit/session/headers.rb', line 56 def @opts['grpc-message'] end |