Skip to content
instance method

Net::HTTPHeader#each

() { (::String, ::String) -> untyped } -> ::Hash[::String, ::Array[::String]]
() -> ::Enumerator[[ ::String, ::String ], ::Hash[::String, ::Array[::String]]]
each

Alias of #each_header

Calls the block with each key/value pair:

Example
res = Net::HTTP.get_response(hostname, '/todos/1')
res.each_header do |key, value|
  p [key, value] if key.start_with?('c')
end

Output:

Example
["content-type", "application/json; charset=utf-8"]
["connection", "keep-alive"]
["cache-control", "max-age=43200"]
["cf-cache-status", "HIT"]
["cf-ray", "771d17e9bc542cf5-ORD"]

Returns an enumerator if no block is given.

Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header.