Protocol::HTTPSourceProtocolHTTPHeaderETag

class ETag

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.

Definitions

def self.parse(value)

Parses a raw header value.

Signature

parameter value String

a raw header value.

returns ETag

a new instance.

Implementation

def self.parse(value)
	self.new(value)
end

def self.coerce(value)

Coerces a value into a parsed header object.

Signature

parameter value String

the value to coerce.

returns ETag

a parsed header object.

Implementation

def self.coerce(value)
	self.new(value.to_s)
end

def <<(value)

Replaces the current value of the etag header.

Signature

parameter value String

a raw header value for the etag header.

Implementation

def << value
	replace(value)
end

def weak?

Checks whether the etag is a weak validator.

Weak validators indicate semantically equivalent content but may not be byte-for-byte identical.

Signature

returns Boolean

whether the etag is weak.

Implementation

def weak?
	self.start_with?("W/")
end

def self.trailer?

Whether this header is acceptable in HTTP trailers. ETag headers can safely appear in trailers as they provide cache validation metadata.

Signature

returns Boolean

true, as ETag headers are metadata that can be computed after response generation.

Implementation

def self.trailer?
	true
end