Class: ApiAuth::RequestDrivers::HttpiRequest
- Inherits:
-
Object
- Object
- ApiAuth::RequestDrivers::HttpiRequest
show all
- Includes:
- Helpers
- Defined in:
- lib/api_auth/request_drivers/httpi.rb
Overview
Instance Method Summary
collapse
Methods included from Helpers
#b64_encode, #capitalize_keys, #md5_base64digest
Constructor Details
Returns a new instance of HttpiRequest.
6
7
8
9
10
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 6
def initialize(request)
@request = request
true
end
|
Instance Method Details
69
70
71
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 69
def
%w[Authorization AUTHORIZATION HTTP_AUTHORIZATION]
end
|
#calculated_md5 ⇒ Object
18
19
20
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 18
def calculated_md5
md5_base64digest(@request.body || '')
end
|
#content_md5 ⇒ Object
48
49
50
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 48
def content_md5
(%w[CONTENT-MD5 CONTENT_MD5])
end
|
#content_type ⇒ Object
44
45
46
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 44
def content_type
(%w[CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE])
end
|
36
37
38
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 36
def
= capitalize_keys @request.
end
|
#http_method ⇒ Object
40
41
42
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 40
def http_method
nil
end
|
#md5_mismatch? ⇒ Boolean
28
29
30
31
32
33
34
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 28
def md5_mismatch?
if @request.body
calculated_md5 != content_md5
else
false
end
end
|
#original_uri ⇒ Object
52
53
54
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 52
def original_uri
(%w[X-ORIGINAL-URI X_ORIGINAL_URI HTTP_X_ORIGINAL_URI])
end
|
#populate_content_md5 ⇒ Object
22
23
24
25
26
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 22
def populate_content_md5
return unless @request.body
@request.['Content-MD5'] = calculated_md5
end
|
#request_uri ⇒ Object
56
57
58
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 56
def request_uri
@request.url.request_uri
end
|
12
13
14
15
16
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 12
def ()
@request.['Authorization'] =
@request
end
|
#set_date ⇒ Object
60
61
62
63
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 60
def set_date
@request.['DATE'] = Time.now.utc.httpdate
end
|
#timestamp ⇒ Object
65
66
67
|
# File 'lib/api_auth/request_drivers/httpi.rb', line 65
def timestamp
(%w[DATE HTTP_DATE])
end
|