Module: Vigiles::Utilities::HTTP

Extended by:
T::Sig
Defined in:
lib/vigiles/utilities/http.rb

Constant Summary collapse

WellKnownHttpHeader =
Vigiles::Types::WellKnownHttpHeader
ContentType =
Vigiles::Types::ContentType

Class Method Summary collapse

Class Method Details

.sanitize_header_value(header:, value:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vigiles/utilities/http.rb', line 20

def self.sanitize_header_value(header:, value:)
  # don't attempt to sanitize values for relatively unknown
  # headers. for example, custom headers (those with the x
  # prefix). obviously if the value is blank then no sanitization
  # is necessary.
  return value if value.blank? || !well_known?(header)

  case header.downcase
  when "content-type" then sanitize_content_type(value.strip)
  else raise ArgumentError, header
  end
end