Class: ApiAuth::RequestDrivers::CurbRequest

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/api_auth/request_drivers/curb.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from Helpers

#b64_encode, #capitalize_keys

Constructor Details

#initialize(request) ⇒ CurbRequest

Returns a new instance of CurbRequest.


9
10
11
12
13
# File 'lib/api_auth/request_drivers/curb.rb', line 9

def initialize(request)
  @request = request
  @headers = fetch_headers
  true
end

Instance Method Details

#authorization_headerObject


56
57
58
# File 'lib/api_auth/request_drivers/curb.rb', line 56

def authorization_header
  find_header %w(Authorization AUTHORIZATION HTTP_AUTHORIZATION)
end

#content_md5Object


38
39
40
41
# File 'lib/api_auth/request_drivers/curb.rb', line 38

def content_md5
  value = find_header(%w(CONTENT-MD5 CONTENT_MD5))
  value.nil? ? "" : value
end

#content_typeObject


33
34
35
36
# File 'lib/api_auth/request_drivers/curb.rb', line 33

def content_type
  value = find_header(%w(CONTENT-TYPE CONTENT_TYPE HTTP_CONTENT_TYPE))
  value.nil? ? "" : value
end

#fetch_headersObject


29
30
31
# File 'lib/api_auth/request_drivers/curb.rb', line 29

def fetch_headers
  capitalize_keys @request.headers
end

#md5_mismatch?Boolean

Returns:

  • (Boolean)

25
26
27
# File 'lib/api_auth/request_drivers/curb.rb', line 25

def md5_mismatch?
  false
end

#populate_content_md5Object


21
22
23
# File 'lib/api_auth/request_drivers/curb.rb', line 21

def populate_content_md5
  nil #doesn't appear to be possible
end

#request_uriObject


43
44
45
# File 'lib/api_auth/request_drivers/curb.rb', line 43

def request_uri
  @request.url
end

#set_auth_header(header) ⇒ Object


15
16
17
18
19
# File 'lib/api_auth/request_drivers/curb.rb', line 15

def set_auth_header(header)
  @request.headers.merge!({ "Authorization" => header })
  @headers = fetch_headers
  @request
end

#set_dateObject


47
48
49
# File 'lib/api_auth/request_drivers/curb.rb', line 47

def set_date
  @request.headers.merge!({ "DATE" => Time.now.utc.httpdate })
end

#timestampObject


51
52
53
54
# File 'lib/api_auth/request_drivers/curb.rb', line 51

def timestamp
  value = find_header(%w(DATE HTTP_DATE))
  value.nil? ? "" : value
end