Class: Protocol::GRPC::Header::Encoding
- Inherits:
-
String
- Object
- String
- Protocol::GRPC::Header::Encoding
- Defined in:
- lib/protocol/grpc/header/encoding.rb
Overview
The grpc-encoding header represents the message compression encoding.
The grpc-encoding header specifies the compression algorithm used for the message payload.
Common values include "identity" (no compression), "gzip", "deflate", etc.
This header can appear in both request and response headers, but not in trailers.
Class Method Summary collapse
-
.coerce(value) ⇒ Object
Coerce a value to an Encoding instance.
-
.parse(value) ⇒ Object
Parse an encoding from a header value.
-
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Merge another encoding value (takes the new value, as encoding should only appear once).
-
#identity? ⇒ Boolean
Check if this encoding represents no compression (identity encoding).
-
#initialize(value) ⇒ Encoding
constructor
Initialize the encoding header with the given value.
Constructor Details
#initialize(value) ⇒ Encoding
Initialize the encoding header with the given value.
35 36 37 |
# File 'lib/protocol/grpc/header/encoding.rb', line 35 def initialize(value) super(value.to_s) end |
Class Method Details
.coerce(value) ⇒ Object
Coerce a value to an Encoding instance. Used by Protocol::HTTP::Headers when setting header values.
28 29 30 |
# File 'lib/protocol/grpc/header/encoding.rb', line 28 def self.coerce(value) new(value.to_s) end |
.parse(value) ⇒ Object
Parse an encoding from a header value.
19 20 21 |
# File 'lib/protocol/grpc/header/encoding.rb', line 19 def self.parse(value) new(value) end |
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers.
The grpc-encoding header does not appear in trailers.
57 58 59 |
# File 'lib/protocol/grpc/header/encoding.rb', line 57 def self.trailer? false end |
Instance Method Details
#<<(value) ⇒ Object
Merge another encoding value (takes the new value, as encoding should only appear once)
48 49 50 51 52 |
# File 'lib/protocol/grpc/header/encoding.rb', line 48 def <<(value) replace(value.to_s) return self end |
#identity? ⇒ Boolean
Check if this encoding represents no compression (identity encoding).
42 43 44 |
# File 'lib/protocol/grpc/header/encoding.rb', line 42 def identity? self == "identity" || self.empty? end |