Class: ApiAuth::RequestDrivers::RestClientRequest
- Inherits:
-
Object
- Object
- ApiAuth::RequestDrivers::RestClientRequest
show all
- Includes:
- Helpers
- Defined in:
- lib/api_auth/request_drivers/rest_client.rb
Overview
Instance Method Summary
collapse
Methods included from Helpers
#b64_encode, #capitalize_keys, #md5_base64digest
Constructor Details
Returns a new instance of RestClientRequest.
9
10
11
12
13
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 9
def initialize(request)
@request = request
=
true
end
|
Instance Method Details
78
79
80
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 78
def
%w[Authorization AUTHORIZATION HTTP_AUTHORIZATION]
end
|
#calculated_md5 ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 21
def calculated_md5
if @request.payload
body = @request.payload.read
@request.payload.instance_variable_get(:@stream).seek(0)
else
body = ''
end
md5_base64digest(body)
end
|
#content_md5 ⇒ Object
57
58
59
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 57
def content_md5
(%w[CONTENT-MD5 CONTENT_MD5])
end
|
#content_type ⇒ Object
53
54
55
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 53
def content_type
(%w[CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE])
end
|
45
46
47
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 45
def
capitalize_keys @request.
end
|
#http_method ⇒ Object
49
50
51
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 49
def http_method
@request.method.to_s.upcase
end
|
#md5_mismatch? ⇒ Boolean
37
38
39
40
41
42
43
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 37
def md5_mismatch?
if i[post put].include?(@request.method)
calculated_md5 != content_md5
else
false
end
end
|
#original_uri ⇒ Object
61
62
63
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 61
def original_uri
(%w[X-ORIGINAL-URI X_ORIGINAL_URI HTTP_X_ORIGINAL_URI])
end
|
#populate_content_md5 ⇒ Object
31
32
33
34
35
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 31
def populate_content_md5
return unless i[post put].include?(@request.method)
@request.['Content-MD5'] = calculated_md5
end
|
#request_uri ⇒ Object
65
66
67
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 65
def request_uri
@request.url
end
|
15
16
17
18
19
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 15
def ()
@request.['Authorization'] =
@request
end
|
#set_date ⇒ Object
69
70
71
72
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 69
def set_date
@request.['DATE'] = Time.now.utc.httpdate
end
|
#timestamp ⇒ Object
74
75
76
|
# File 'lib/api_auth/request_drivers/rest_client.rb', line 74
def timestamp
(%w[DATE HTTP_DATE])
end
|