Module: AuthHMAC::Headers
- Included in:
- AuthHMAC, CanonicalString
- Defined in:
- lib/auth-hmac.rb
Overview
:nodoc:
Instance Method Summary collapse
- #find_header(keys, headers) ⇒ Object
-
#headers(request) ⇒ Object
Gets the headers for a request.
Instance Method Details
#find_header(keys, headers) ⇒ Object
49 50 51 52 53 |
# File 'lib/auth-hmac.rb', line 49 def find_header(keys, headers) keys.map do |key| headers[key] end.compact.first end |
#headers(request) ⇒ Object
Gets the headers for a request.
Attempts to deal with known HTTP header representations in Ruby. Currently handles net/http and Rails.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/auth-hmac.rb', line 32 def headers(request) if request.respond_to?(:headers) request.headers elsif request.respond_to?(:env) request.env.each_pair do |key,value| if value.is_a?(Array) && value.size == 1 request.env[key] = value[0] end end request.env elsif request.respond_to?(:[]) request else raise ArgumentError, "Don't know how to get the headers from #{request.inspect}" end end |