Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#each_capitalized_name
() { (::String) -> untyped } -> ::Hash[::String, ::Array[::String]]
() -> ::Enumerator[::String, ::Hash[::String, ::Array[::String]]]
each_capitalized_name() { |key| ... }
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/net/http/header.rb, line 417
def each_capitalized_name #:yield: +key+
block_given? or return enum_for(__method__) { @header.size }
@header.each_key do |k|
yield capitalize(k)
end
end
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.