lib/api_auth/request_drivers/httpi.rb in api-auth-1.5.0 vs lib/api_auth/request_drivers/httpi.rb in api-auth-2.0.0
- old
+ new
@@ -1,32 +1,29 @@
module ApiAuth
-
module RequestDrivers # :nodoc:
-
class HttpiRequest # :nodoc:
-
include ApiAuth::Helpers
def initialize(request)
@request = request
fetch_headers
true
end
def set_auth_header(header)
- @request.headers["Authorization"] = header
+ @request.headers['Authorization'] = header
fetch_headers
@request
end
def calculated_md5
md5_base64digest(@request.body || '')
end
def populate_content_md5
if @request.body
- @request.headers["Content-MD5"] = calculated_md5
+ @request.headers['Content-MD5'] = calculated_md5
fetch_headers
end
end
def md5_mismatch?
@@ -45,42 +42,39 @@
nil # not possible to get the method at this layer
end
def content_type
value = find_header(%w(CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE))
- value.nil? ? "" : value
+ value.nil? ? '' : value
end
def content_md5
value = find_header(%w(CONTENT-MD5 CONTENT_MD5))
- value.nil? ? "" : value
+ value.nil? ? '' : value
end
def request_uri
@request.url.request_uri
end
def set_date
- @request.headers["DATE"] = Time.now.utc.httpdate
+ @request.headers['DATE'] = Time.now.utc.httpdate
fetch_headers
end
def timestamp
value = find_header(%w(DATE HTTP_DATE))
- value.nil? ? "" : value
+ value.nil? ? '' : value
end
def authorization_header
find_header %w(Authorization AUTHORIZATION HTTP_AUTHORIZATION)
end
- private
+ private
def find_header(keys)
- keys.map {|key| @headers[key] }.compact.first
+ keys.map { |key| @headers[key] }.compact.first
end
-
end
-
end
-
end