Class: Protocol::HTTP::Header::TransferEncoding
- Defined in:
- lib/protocol/http/header/transfer_encoding.rb
Overview
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.
Constant Summary collapse
- CHUNKED =
The ‘chunked` transfer encoding allows a server to send data of unknown length by breaking it into chunks.
"chunked"- GZIP =
The ‘gzip` transfer encoding compresses the message body using the gzip algorithm.
"gzip"- DEFLATE =
The ‘deflate` transfer encoding compresses the message body using the deflate algorithm.
"deflate"- COMPRESS =
The ‘compress` transfer encoding compresses the message body using the compress algorithm.
"compress"- IDENTITY =
The ‘identity` transfer encoding indicates no transformation has been applied.
"identity"
Constants inherited from Split
Class Method Summary collapse
-
.coerce(value) ⇒ Object
Coerces a value into a parsed header object.
-
.parse(value) ⇒ Object
Parses a raw header value.
-
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers.
Instance Method Summary collapse
-
#<<(value) ⇒ Object
Adds one or more comma-separated values to the transfer encoding header.
- #chunked? ⇒ Boolean
- #compress? ⇒ Boolean
- #deflate? ⇒ Boolean
- #gzip? ⇒ Boolean
- #identity? ⇒ Boolean
Methods inherited from Split
Constructor Details
This class inherits a constructor from Protocol::HTTP::Header::Split
Class Method Details
.coerce(value) ⇒ Object
Coerces a value into a parsed header object.
42 43 44 45 46 47 48 49 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 42 def self.coerce(value) case value when Array self.new(value.map(&:downcase)) else self.parse(value.to_s) end end |
.parse(value) ⇒ Object
Parses a raw header value.
34 35 36 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 34 def self.parse(value) self.new(value.downcase.split(COMMA)) end |
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers. Transfer-Encoding headers control message framing and must not appear in trailers.
86 87 88 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 86 def self.trailer? false end |
Instance Method Details
#<<(value) ⇒ Object
Adds one or more comma-separated values to the transfer encoding header. The values are converted to lowercase for normalization.
54 55 56 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 54 def << value super(value.downcase) end |
#chunked? ⇒ Boolean
59 60 61 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 59 def chunked? self.include?(CHUNKED) end |
#compress? ⇒ Boolean
74 75 76 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 74 def compress? self.include?(COMPRESS) end |
#deflate? ⇒ Boolean
69 70 71 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 69 def deflate? self.include?(DEFLATE) end |
#gzip? ⇒ Boolean
64 65 66 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 64 def gzip? self.include?(GZIP) end |
#identity? ⇒ Boolean
79 80 81 |
# File 'lib/protocol/http/header/transfer_encoding.rb', line 79 def identity? self.include?(IDENTITY) end |