Skip to content

Commit ae0834e

Browse files
committed
Documentation.
1 parent c4adb7b commit ae0834e

File tree

11 files changed

+40
-7
lines changed

11 files changed

+40
-7
lines changed

lib/protocol/http/header/accept.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def to_s
9292
join(",")
9393
end
9494

95+
# Whether this header is acceptable in HTTP trailers.
96+
# Accept headers in trailers can provide content negotiation hints for subsequent responses.
97+
# @returns [Boolean] false, as Accept headers are generally not needed in trailers.
9598
def self.trailer?
9699
false
97100
end

lib/protocol/http/header/authorization.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ def self.basic(username, password)
3131
strict_base64_encoded = ["#{username}:#{password}"].pack("m0")
3232

3333
self.new(
34-
"Basic #{strict_base64_encoded}"
35-
)
36-
end
37-
38-
def self.trailer?
39-
false
40-
end
34+
"Basic #{strict_base64_encoded}"
35+
)
36+
end
37+
38+
# Whether this header is acceptable in HTTP trailers.
39+
# Authorization credentials must not appear in trailers for security reasons.
40+
# @returns [Boolean] false, as authorization headers contain sensitive credentials.
41+
def self.trailer?
42+
false
43+
end
4144
end
4245
end
4346
end

lib/protocol/http/header/connection.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def upgrade?
5151
self.include?(UPGRADE)
5252
end
5353

54+
# Whether this header is acceptable in HTTP trailers.
55+
# Connection headers control the current connection and must not appear in trailers.
56+
# @returns [Boolean] false, as connection headers are hop-by-hop and forbidden in trailers.
5457
def self.trailer?
5558
false
5659
end

lib/protocol/http/header/cookie.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ def to_h
2424
cookies.map{|cookie| [cookie.name, cookie]}.to_h
2525
end
2626

27+
# Whether this header is acceptable in HTTP trailers.
28+
# Cookie headers should not appear in trailers as they contain state information needed early in processing.
29+
# @returns [Boolean] false, as cookie headers are needed during initial request processing.
2730
def self.trailer?
2831
false
2932
end

lib/protocol/http/header/date.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def to_time
2626
::Time.parse(self)
2727
end
2828

29+
# Whether this header is acceptable in HTTP trailers.
30+
# Date headers can safely appear in trailers as they provide metadata about response generation.
31+
# @returns [Boolean] true, as date headers are metadata that can be computed after response generation.
2932
def self.trailer?
3033
true
3134
end

lib/protocol/http/header/etag.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def weak?
2626
self.start_with?("W/")
2727
end
2828

29+
# Whether this header is acceptable in HTTP trailers.
30+
# ETag headers can safely appear in trailers as they provide cache validation metadata.
31+
# @returns [Boolean] true, as ETag headers are metadata that can be computed after response generation.
2932
def self.trailer?
3033
true
3134
end

lib/protocol/http/header/multiple.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ def to_s
2626
join("\n")
2727
end
2828

29+
# Whether this header is acceptable in HTTP trailers.
30+
# This is a base class for headers with multiple values, default is to disallow in trailers.
31+
# @returns [Boolean] false, as most multiple-value headers should not appear in trailers by default.
2932
def self.trailer?
3033
false
3134
end

lib/protocol/http/header/split.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def to_s
4040
join(",")
4141
end
4242

43+
# Whether this header is acceptable in HTTP trailers.
44+
# This is a base class for comma-separated headers, default is to disallow in trailers.
45+
# @returns [Boolean] false, as most comma-separated headers should not appear in trailers by default.
4346
def self.trailer?
4447
false
4548
end

lib/protocol/http/header/te.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def trailers?
119119
self.any? {|value| value.start_with?(TRAILERS)}
120120
end
121121

122+
# Whether this header is acceptable in HTTP trailers.
123+
# TE headers negotiate transfer encodings and must not appear in trailers.
124+
# @returns [Boolean] false, as TE headers are hop-by-hop and control message framing.
122125
def self.trailer?
123126
false
124127
end

lib/protocol/http/header/trailer.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ module Header
1212
#
1313
# This isn't a specific header class is a utility for handling headers with comma-separated values, such as `accept`, `cache-control`, and other similar headers. The values are split and stored as an array internally, and serialized back to a comma-separated string when needed.
1414
class Trailer < Split
15+
# Whether this header is acceptable in HTTP trailers.
16+
# Trailer headers themselves must not appear in trailers to avoid recursive references.
17+
# @returns [Boolean] false, as Trailer headers control trailer processing and must appear before the message body.
1518
def self.trailer?
1619
false
1720
end

0 commit comments

Comments
 (0)