class TransferEncoding
The transfer-encoding
header indicates the encoding transformations that have been applied to the message body.
The transfer-encoding
header is used to specify the form of encoding used to safely transfer the message body between the sender and receiver.
Definitions
CHUNKED = "chunked"
The chunked
transfer encoding allows a server to send data of unknown length by breaking it into chunks.
GZIP = "gzip"
The gzip
transfer encoding compresses the message body using the gzip algorithm.
DEFLATE = "deflate"
The deflate
transfer encoding compresses the message body using the deflate algorithm.
COMPRESS = "compress"
The compress
transfer encoding compresses the message body using the compress algorithm.
IDENTITY = "identity"
The identity
transfer encoding indicates no transformation has been applied.
def initialize(value = nil)
Initializes the transfer encoding header with the given value. The value is split into distinct entries and converted to lowercase for normalization.
Signature
-
parameter
value
String | Nil
the raw header value containing transfer encodings separated by commas.
Implementation
def initialize(value = nil)
super(value&.downcase)
end
def <<(value)
Adds one or more comma-separated values to the transfer encoding header. The values are converted to lowercase for normalization.
Signature
-
parameter
value
String
the value or values to add, separated by commas.
Implementation
def << value
super(value.downcase)
end
def chunked?
Signature
-
returns
Boolean
whether the
chunked
encoding is present.
Implementation
def chunked?
self.include?(CHUNKED)
end
def gzip?
Signature
-
returns
Boolean
whether the
gzip
encoding is present.
Implementation
def gzip?
self.include?(GZIP)
end
def deflate?
Signature
-
returns
Boolean
whether the
deflate
encoding is present.
Implementation
def deflate?
self.include?(DEFLATE)
end
def compress?
Signature
-
returns
Boolean
whether the
compress
encoding is present.
Implementation
def compress?
self.include?(COMPRESS)
end
def identity?
Signature
-
returns
Boolean
whether the
identity
encoding is present.
Implementation
def identity?
self.include?(IDENTITY)
end
def self.trailer?
Whether this header is acceptable in HTTP trailers. Transfer-Encoding headers control message framing and must not appear in trailers.
Signature
-
returns
Boolean
false
, as Transfer-Encoding headers are hop-by-hop and must precede the message body.
Implementation
def self.trailer?
false
end