class Vary
Represents the vary header, which specifies the request headers a server considers when determining the response.
The vary header is used in HTTP responses to indicate which request headers affect the selected response. It allows caches to differentiate stored responses based on specific request headers.
Definitions
def self.parse(value)
Parses a raw header value.
Signature
-
parameter
valueString a raw header value containing comma-separated header names.
-
returns
Vary a new instance with normalized (lowercase) header names.
Implementation
def self.parse(value)
self.new(value.downcase.split(COMMA))
end
def self.coerce(value)
Coerces a value into a parsed header object.
Signature
-
parameter
valueString | Array the value to coerce.
-
returns
Vary a parsed header object with normalized values.
Implementation
def self.coerce(value)
case value
when Array
self.new(value.map(&:downcase))
else
self.parse(value.to_s)
end
end
def <<(value)
Adds one or more comma-separated values to the vary header. The values are converted to lowercase for normalization.
Signature
-
parameter
valueString a raw header value containing one or more values separated by commas.
Implementation
def << value
super(value.downcase)
end