Class: AzureBlob::CanonicalizedResource

Inherits:
Object
  • Object
show all
Defined in:
lib/azure_blob/canonicalized_resource.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(uri, account_name, service_name: nil, url_safe: true) ⇒ CanonicalizedResource

Returns a new instance of CanonicalizedResource.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/azure_blob/canonicalized_resource.rb', line 5

def initialize(uri, , service_name: nil, url_safe: true)
  # This next line is needed because CanonicalizedResource
  # need to be escaped for auhthorization headers, but not SAS tokens
  path = url_safe ? uri.path : URI::RFC2396_PARSER.unescape(uri.path)
  resource = "/#{}#{path.empty? ? "/" : path}"
  resource = "/#{service_name}#{resource}" if service_name
  params = CGI.parse(uri.query.to_s)
    .transform_keys(&:downcase)
    .sort
    .map { |param, value| "#{param}:#{value.map(&:strip).sort.join(",")}" }

  @canonicalized_resource = [ resource, *params ].join("\n")
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/azure_blob/canonicalized_resource.rb', line 19

def to_s
  @canonicalized_resource
end