class Seahorse::Client::Http::Headers
#=> { ‘content-length’ => ‘100’, ‘authorization’ => ‘Abc’ }
headers.to_h
You can get the header values as a vanilla hash by calling {#to_h}:
#=> [‘100’, ‘Abc’]
headers.values
#=> [‘content-length’, ‘authorization’]<br>headers.keys<br><br>headers = ‘Abc’<br>headers = 100
headers = Http::Headers.new
are cast to strings.
are treated indifferently as lower-cased strings. Header values
Provides a Hash-like interface for HTTP headers. Header names
def [](key)
-
(String)
-
Parameters:
-
key
(String
) --
def [](key) @data[key.to_s.downcase] end
def []=(key, value)
-
value
(String
) -- -
key
(String
) --
def []=(key, value) @data[key.to_s.downcase] = value.to_s end
def clear
def clear @data = {} end
def delete(key)
-
key
(String
) --
def delete(key) @data.delete(key.to_s.downcase) end
def each(&block)
-
(nil)
-
Other tags:
- Yieldparam: value -
Yieldparam: key -
Other tags:
- Yield: -
def each(&block) if block_given? @data.each_pair do |key, value| yield(key, value) end nil else @data.enum_for(:each) end end
def initialize(headers = {})
- Api: - private
def initialize(headers = {}) @data = {} headers.each_pair do |key, value| self[key] = value end end
def inspect
- Api: - private
def inspect @data.inspect end
def key?(key)
-
(Boolean)
- Returns `true` if the header is set.
def key?(key) @data.key?(key.to_s.downcase) end
def keys
-
(Array
-)
def keys @data.keys end
def to_hash
-
(Hash)
-
def to_hash @data.dup end
def update(headers)
-
(Headers)
-
Parameters:
-
headers
(Hash
) --
def update(headers) headers.each_pair do |k, v| self[k] = v end self end
def values
-
(Array
-)
def values @data.values end
def values_at(*keys)
-
(Array
-)
def values_at(*keys) @data.values_at(*keys.map{ |key| key.to_s.downcase }) end