File: vary.rb

package info (click to toggle)
ruby-protocol-http 0.55.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 840 kB
  • sloc: ruby: 6,904; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 1,135 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020-2025, by Samuel Williams.

require_relative "split"

module Protocol
	module HTTP
		module Header
			# 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.
			class Vary < Split
				# Initializes a `Vary` header with the given value. The value is split into distinct entries and converted to lowercase for normalization.
				#
				# @parameter value [String] the raw header value containing request header names separated by commas.
				def initialize(value)
					super(value.downcase)
				end
				
				# Adds one or more comma-separated values to the `vary` header. The values are converted to lowercase for normalization.
				#
				# @parameter value [String] the value or values to add, separated by commas.
				def << value
					super(value.downcase)
				end
			end
		end
	end
end