Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

Net::HTTPHeader#each_capitalized_name

each_capitalized_name() { |key| ... }

Calls the block with each capitalized field name:

Example
res = Net::HTTP.get_response(hostname, '/todos/1')
res.each_capitalized_name do |key|
  p key if key.start_with?('C')
end

Output:

Example
"Content-Type"
"Connection"
"Cache-Control"
"Cf-Cache-Status"
"Cf-Ray"

The capitalization is system-dependent; see Case Mapping.

Returns an enumerator if no block is given.

See also #each_capitalized #each_header #each #each_key also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0