Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#each_key
() { (::String) -> untyped } -> ::Hash[::String, ::Array[::String]]
() -> ::Enumerator[::String, ::Hash[::String, ::Array[::String]]]
each_key
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.4.1/lib/net/http/header.rb, line 391
def each_name(&block) #:yield: +key+
block_given? or return enum_for(__method__) { @header.size }
@header.each_key(&block)
end
Alias of #each_name
Calls the block with each field key:
Example
res = Net::HTTP.get_response(hostname, '/todos/1') res.each_key do |key| p key if key.start_with?('c') end
Output:
Example
"content-type" "connection" "cache-control" "cf-cache-status" "cf-ray"
Returns an enumerator if no block is given.
Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key.
See also
#each_name
#each_header
#each_capitalized_name
#each_value
also in
4.1 · 4.0 · 3.3 · 3.2 · 3.1 · 3.0