Sha256: d0d37766eecaace71bb6d9a9c3506d1d3c221212dde13fc03f5b82ec4c4d327d

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Storage
    class GoogleJSON
      module Utils
        def http_url(params, expires)
          "http://" << host_path_query(params, expires)
        end

        def https_url(params, expires)
          "https://" << host_path_query(params, expires)
        end

        def url(params, expires)
          Fog::Logger.deprecation("Fog::Storage::Google => #url is deprecated, use #https_url instead [light_black](#{caller.first})[/]")
          https_url(params, expires)
        end

        private

        def host_path_query(params, expires)
          params[:headers]["Date"] = expires.to_i
          # implementation from CGI.escape, but without ' ' to  '+' conversion
          params[:path] = params[:path].b.gsub(/([^a-zA-Z0-9_.\-~]+)/) { |m|
            '%' + m.unpack('H2' * m.bytesize).join('%').upcase
          }.gsub("%2F", "/")

          query = []

          if params[:query]
            filtered = params[:query].reject { |k, v| k.nil? || v.nil? }
            query = filtered.map { |k, v| [k.to_s, Fog::Google.escape(v)].join("=") }
          end

          query << "GoogleAccessId=#{google_access_id}"
          query << "Signature=#{CGI.escape(signature(params))}"
          query << "Expires=#{params[:headers]['Date']}"
          "#{params[:host]}/#{params[:path]}?#{query.join('&')}"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-google-1.20.0 lib/fog/storage/google_json/utils.rb
fog-google-1.19.0 lib/fog/storage/google_json/utils.rb
fog-google-1.18.0 lib/fog/storage/google_json/utils.rb
fog-google-1.17.0 lib/fog/storage/google_json/utils.rb
fog-google-1.16.1 lib/fog/storage/google_json/utils.rb
fog-google-1.16.0 lib/fog/storage/google_json/utils.rb
fog-google-1.15.0 lib/fog/storage/google_json/utils.rb
fog-google-1.14.0 lib/fog/storage/google_json/utils.rb