Class: Protocol::HTTP::Header::TransferEncoding

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

Split::COMMA

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Split

#to_s

Constructor Details

#initialize(value = nil) ⇒ TransferEncoding

Initializes the transfer encoding header with the given value. The value is split into distinct entries and converted to lowercase for normalization.



33
34
35
# File 'lib/protocol/http/header/transfer_encoding.rb', line 33

def initialize(value = nil)
	super(value&.downcase)
end

Class Method Details

.trailer?Boolean

Whether this header is acceptable in HTTP trailers. Transfer-Encoding headers control message framing and must not appear in trailers.

Returns:

  • (Boolean)


72
73
74
# File 'lib/protocol/http/header/transfer_encoding.rb', line 72

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.



40
41
42
# File 'lib/protocol/http/header/transfer_encoding.rb', line 40

def << value
	super(value.downcase)
end

#chunked?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/protocol/http/header/transfer_encoding.rb', line 45

def chunked?
	self.include?(CHUNKED)
end

#compress?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/protocol/http/header/transfer_encoding.rb', line 60

def compress?
	self.include?(COMPRESS)
end

#deflate?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/protocol/http/header/transfer_encoding.rb', line 55

def deflate?
	self.include?(DEFLATE)
end

#gzip?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/protocol/http/header/transfer_encoding.rb', line 50

def gzip?
	self.include?(GZIP)
end

#identity?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/protocol/http/header/transfer_encoding.rb', line 65

def identity?
	self.include?(IDENTITY)
end