class Azure::Core::Http::HttpResponse::HeaderHash
Since HTTP Headers are case insensitive, this class will normalize them to lowercase. This also wraps Net::HTTPResponse headers by returning their values as strings, not arrays, by selecting the first value from the array.
Public Class Methods
new(headers)
click to toggle source
Public: Initialize the header hash.
headers - A Hash of headers as returned from Net::HTTPResponse#to_hash.
Calls superclass method
# File lib/azure/core/http/http_response.rb, line 88 def initialize(headers) super headers = Hash[headers.map { |k,v| [k.downcase.freeze, v.first.freeze] }] replace(headers) end
Public Instance Methods
[](header)
click to toggle source
Public: Get a header's value or nil if it's not present.
header - A string with the header's name.
Returns a String
or nil.
Calls superclass method
# File lib/azure/core/http/http_response.rb, line 99 def [](header) super(header.downcase) end
fetch(header, *default, &block)
click to toggle source
Public: Get a header's value or a specified default.
header - A string with the header's name. default - A default value.
Yields a block where you can specify the default value.
Returns a String
, or the specified default.
Calls superclass method
# File lib/azure/core/http/http_response.rb, line 111 def fetch(header, *default, &block) if (args = default.size) > 1 raise ArgumentError, "wrong number of arguments(#{args + 1} for 2)" end super(header.downcase, *default, &block) end