Public Instance methods
canonical_path()
[show source]
# File lib/httpx/plugins/aws_sigv4.rb 183 def canonical_path 184 path = uri.path.dup 185 path << "/" if path.empty? 186 path.gsub(%r{[^/]+}) { |part| CGI.escape(part.encode("UTF-8")).gsub("+", "%20").gsub("%7E", "~") } 187 end
canonical_query()
[show source]
# File lib/httpx/plugins/aws_sigv4.rb 189 def canonical_query 190 params = query.split("&") 191 # params = params.map { |p| p.match(/=/) ? p : p + '=' } 192 # From: https://docs.aws.amazon.com/IAM/latest/UserGuide/create-signed-request.html#create-canonical-request 193 # Sort the parameter names by character code point in ascending order. 194 # Parameters with duplicate names should be sorted by value. 195 # 196 # Default sort <=> in JRuby will swap members 197 # occasionally when <=> is 0 (considered still sorted), but this 198 # causes our normalized query string to not match the sent querystring. 199 # When names match, we then sort by their values. When values also 200 # match then we sort by their original order 201 params.each.with_index.sort do |a, b| 202 a, a_offset = a 203 b, b_offset = b 204 a_name, a_value = a.split("=", 2) 205 b_name, b_value = b.split("=", 2) 206 if a_name == b_name 207 if a_value == b_value 208 a_offset <=> b_offset 209 else 210 a_value <=> b_value 211 end 212 else 213 a_name <=> b_name 214 end 215 end.map(&:first).join("&") 216 end