Class: Protocol::HTTP::Header::ETag
- Inherits:
-
String
- Object
- String
- Protocol::HTTP::Header::ETag
- Defined in:
- lib/protocol/http/header/etag.rb
Overview
The ‘etag` header represents the entity tag for a resource.
The ‘etag` header provides a unique identifier for a specific version of a resource, typically used for cache validation or conditional requests. It can be either a strong or weak validator as defined in RFC 9110.
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
Replaces the current value of the ‘etag` header.
-
#weak? ⇒ Boolean
Checks whether the ‘etag` is a weak validator.
Class Method Details
.coerce(value) ⇒ Object
Coerces a value into a parsed header object.
25 26 27 |
# File 'lib/protocol/http/header/etag.rb', line 25 def self.coerce(value) self.new(value.to_s) end |
.parse(value) ⇒ Object
Parses a raw header value.
17 18 19 |
# File 'lib/protocol/http/header/etag.rb', line 17 def self.parse(value) self.new(value) end |
.trailer? ⇒ Boolean
Whether this header is acceptable in HTTP trailers. ETag headers can safely appear in trailers as they provide cache validation metadata.
48 49 50 |
# File 'lib/protocol/http/header/etag.rb', line 48 def self.trailer? true end |
Instance Method Details
#<<(value) ⇒ Object
Replaces the current value of the ‘etag` header.
32 33 34 |
# File 'lib/protocol/http/header/etag.rb', line 32 def << value replace(value) end |
#weak? ⇒ Boolean
Checks whether the ‘etag` is a weak validator.
Weak validators indicate semantically equivalent content but may not be byte-for-byte identical.
41 42 43 |
# File 'lib/protocol/http/header/etag.rb', line 41 def weak? self.start_with?("W/") end |