Class: GrpcKit::Session::Headers
- Inherits:
-
Struct
- Object
- Struct
- GrpcKit::Session::Headers
- Defined in:
- lib/grpc_kit/session/headers.rb
Constant Summary collapse
- RESERVED_HEADERS =
[ 'content-type', 'user-agent', 'grpc-message-type', 'grpc-encoding', 'grpc-message', 'grpc-status', 'grpc-status-details-bin', 'grpc-accept-encoding', 'te' ].freeze
- IGNORE_HEADERS =
[':method', ':scheme'].freeze
- METADATA_ACCEPTABLE_HEADER =
%w[:authority user-agent].freeze
Instance Attribute Summary collapse
-
#grpc_encoding ⇒ Object
Returns the value of attribute grpc_encoding.
-
#grpc_status ⇒ Object
Returns the value of attribute grpc_status.
-
#http_status ⇒ Object
Returns the value of attribute http_status.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#method ⇒ Object
Returns the value of attribute method.
-
#path ⇒ Object
Returns the value of attribute path.
-
#status_message ⇒ Object
Returns the value of attribute status_message.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #add(key, val) ⇒ Object
-
#initialize ⇒ Headers
constructor
A new instance of Headers.
Constructor Details
#initialize ⇒ Headers
Returns a new instance of Headers.
33 34 35 |
# File 'lib/grpc_kit/session/headers.rb', line 33 def initialize super({}) # set metadata empty hash end |
Instance Attribute Details
#grpc_encoding ⇒ Object
Returns the value of attribute grpc_encoding
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def grpc_encoding @grpc_encoding end |
#grpc_status ⇒ Object
Returns the value of attribute grpc_status
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def grpc_status @grpc_status end |
#http_status ⇒ Object
Returns the value of attribute http_status
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def http_status @http_status end |
#metadata ⇒ Object
Returns the value of attribute metadata
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def @metadata end |
#method ⇒ Object
Returns the value of attribute method
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def method @method end |
#path ⇒ Object
Returns the value of attribute path
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def path @path end |
#status_message ⇒ Object
Returns the value of attribute status_message
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def @status_message end |
#timeout ⇒ Object
Returns the value of attribute timeout
7 8 9 |
# File 'lib/grpc_kit/session/headers.rb', line 7 def timeout @timeout end |
Instance Method Details
#add(key, val) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/grpc_kit/session/headers.rb', line 37 def add(key, val) case key when ':path' self.path = val when ':status' self.http_status = Integer(val) when 'content-type' # self.grpc_encoding = val when 'grpc-encoding' self.grpc_encoding = val when 'grpc-status' self.grpc_status = val when 'grpc-timeout' self.timeout = GrpcTime.new(val) when 'grpc-message' self. = val when 'grpc-status-details-bin' # TODO GrpcKit.logger.warn('grpc-status-details-bin is unsupported header now') else if IGNORE_HEADERS.include?(key) return end if RESERVED_HEADERS.include?(key) && !METADATA_ACCEPTABLE_HEADER.include?(key) return end [key] = val end end |