Class: AuthHMAC::CanonicalString

Inherits:
String
  • Object
show all
Includes:
Headers
Defined in:
lib/auth-hmac.rb

Overview

Build a Canonical String for a HTTP request.

A Canonical String has the following format:

CanonicalString = HTTP-Verb + “n” +

Content-Type + "\n" +
Content-MD5  + "\n" +
Date         + "\n" +
request-uri;

If the Date header doesn’t exist, one will be generated since Net/HTTP will generate one if it doesn’t exist and it will be used on the server side to do authentication.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Headers

#find_header

Constructor Details

#initialize(request, authenticate_referrer = false) ⇒ CanonicalString

Returns a new instance of CanonicalString.



76
77
78
79
80
81
82
# File 'lib/auth-hmac.rb', line 76

def initialize(request, authenticate_referrer=false)
  @request               = request
  @authenticate_referrer = authenticate_referrer
  self << request_method + "\n"
  self << header_values + "\n"
  self << request_path
end

Instance Attribute Details

#authenticate_referrerObject (readonly)

Returns the value of attribute authenticate_referrer.



83
84
85
# File 'lib/auth-hmac.rb', line 83

def authenticate_referrer
  @authenticate_referrer
end

#requestObject (readonly)

Returns the value of attribute request.



83
84
85
# File 'lib/auth-hmac.rb', line 83

def request
  @request
end