From the Amazon docs: CanonicalizedResource = [ "/" + Bucket ] + <HTTP-Request-URI, from the protocol name up to the query string> + [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"];
(buf *bytes.Buffer, req http.Request, virtualHost bool)
| 287 | // <HTTP-Request-URI, from the protocol name up to the query string> + |
| 288 | // [ sub-resource, if present. For example "?acl", "?location", "?logging", or "?torrent"]; |
| 289 | func writeCanonicalizedResource(buf *bytes.Buffer, req http.Request, virtualHost bool) { |
| 290 | // Save request URL. |
| 291 | requestURL := req.URL |
| 292 | // Get encoded URL path. |
| 293 | buf.WriteString(encodeURL2Path(&req, virtualHost)) |
| 294 | if requestURL.RawQuery != "" { |
| 295 | var n int |
| 296 | vals, _ := url.ParseQuery(requestURL.RawQuery) |
| 297 | // Verify if any sub resource queries are present, if yes |
| 298 | // canonicallize them. |
| 299 | for _, resource := range resourceList { |
| 300 | if vv, ok := vals[resource]; ok && len(vv) > 0 { |
| 301 | n++ |
| 302 | // First element |
| 303 | switch n { |
| 304 | case 1: |
| 305 | buf.WriteByte('?') |
| 306 | // The rest |
| 307 | default: |
| 308 | buf.WriteByte('&') |
| 309 | } |
| 310 | buf.WriteString(resource) |
| 311 | // Request parameters |
| 312 | if len(vv[0]) > 0 { |
| 313 | buf.WriteByte('=') |
| 314 | buf.WriteString(vv[0]) |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | } |
| 319 | } |
no test coverage detected