Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
CGI#header
header(options='text/html')
lib/cgi/core.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.3.0/lib/cgi/core.rb, line 160
def http_header(options='text/html')
if options.is_a?(String)
content_type = options
buf = _header_for_string(content_type)
elsif options.is_a?(Hash)
if options.size == 1 && options.has_key?('type')
content_type = options['type']
buf = _header_for_string(content_type)
else
buf = _header_for_hash(options.dup)
end
else
raise ArgumentError.new("expected String or Hash but got #{options.class}")
end
if defined?(MOD_RUBY)
_header_for_modruby(buf)
return ''
else
buf << EOL # empty line of separator
return buf
end
end
Alias of #http_header
This method is an alias for http_header, when HTML5 tag maker is inactive.
NOTE: use http_header to create HTTP header blocks, this alias is only provided for backwards compatibility.
Using header with the HTML5 tag maker will create a <header> element.