Class: Protocol::GRPC::Header::Encoding

Inherits:
String
  • Object
show all
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

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


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).

Returns:

  • (Boolean)


42
43
44
# File 'lib/protocol/grpc/header/encoding.rb', line 42

def identity?
	self == "identity" || self.empty?
end