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, #md5_base64digest

Constructor Details

#initialize(request) ⇒ CurbRequest

Returns a new instance of CurbRequest.



6
7
8
9
10
# File 'lib/api_auth/request_drivers/curb.rb', line 6

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

Instance Method Details

#authorization_headerObject



58
59
60
# File 'lib/api_auth/request_drivers/curb.rb', line 58

def authorization_header
  find_header %w(Authorization AUTHORIZATION HTTP_AUTHORIZATION)
end

#content_md5Object



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

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

#content_typeObject



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

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

#fetch_headersObject



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

def fetch_headers
  @headers = capitalize_keys @request.headers
end

#http_methodObject



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

def http_method
  nil # not possible to get the method at this layer
end

#md5_mismatch?Boolean

Returns:

  • (Boolean)


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

def md5_mismatch?
  false
end

#populate_content_md5Object



18
19
20
# File 'lib/api_auth/request_drivers/curb.rb', line 18

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

#request_uriObject



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

def request_uri
  @request.url
end

#set_auth_header(header) ⇒ Object



12
13
14
15
16
# File 'lib/api_auth/request_drivers/curb.rb', line 12

def set_auth_header(header)
  @request.headers['Authorization'] = header
  fetch_headers
  @request
end

#set_dateObject



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

def set_date
  @request.headers['DATE'] = Time.now.utc.httpdate
  fetch_headers
end

#timestampObject



53
54
55
56
# File 'lib/api_auth/request_drivers/curb.rb', line 53

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