MCPcopy
hub / github.com/minio/minio-go / encodeURL2Path

Function encodeURL2Path

pkg/signer/request-signature-v2.go:42–56  ·  view source on GitHub ↗

Encode input URL path to URL encoded path.

(req *http.Request, virtualHost bool)

Source from the content-addressed store, hash-verified

40
41// Encode input URL path to URL encoded path.
42func encodeURL2Path(req *http.Request, virtualHost bool) (path string) {
43 if virtualHost {
44 reqHost := getHostAddr(req)
45 dotPos := strings.Index(reqHost, ".")
46 if dotPos > -1 {
47 bucketName := reqHost[:dotPos]
48 path = "/" + bucketName
49 path += req.URL.Path
50 path = s3utils.EncodePath(path)
51 return path
52 }
53 }
54 path = s3utils.EncodePath(req.URL.Path)
55 return path
56}
57
58// PreSignV2 - presign the request in following style.
59// https://${S3_BUCKET}.s3.amazonaws.com/${S3_OBJECT}?AWSAccessKeyId=${S3_ACCESS_KEY}&Expires=${TIMESTAMP}&Signature=${SIGNATURE}.

Callers 2

TestEncodeURL2PathFunction · 0.85

Calls 2

EncodePathFunction · 0.92
getHostAddrFunction · 0.85

Tested by 1

TestEncodeURL2PathFunction · 0.68