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

Method createSessionRequest

create-session.go:102–182  ·  view source on GitHub ↗

createSessionRequest - Wrapper creates a new CreateSession request.

(ctx context.Context, bucketName string, sessionMode SessionMode)

Source from the content-addressed store, hash-verified

100
101// createSessionRequest - Wrapper creates a new CreateSession request.
102func (c *Client) createSessionRequest(ctx context.Context, bucketName string, sessionMode SessionMode) (*http.Request, error) {
103 // Set location query.
104 urlValues := make(url.Values)
105 urlValues.Set("session", "")
106
107 // Set get bucket location always as path style.
108 targetURL := *c.endpointURL
109
110 // Fetch new host based on the bucket location.
111 host := getS3ExpressEndpoint(c.region, s3utils.IsS3ExpressBucket(bucketName))
112
113 // as it works in makeTargetURL method from api.go file
114 if h, p, err := net.SplitHostPort(host); err == nil {
115 if targetURL.Scheme == "http" && p == "80" || targetURL.Scheme == "https" && p == "443" {
116 host = h
117 if ip := net.ParseIP(h); ip != nil && ip.To4() == nil {
118 host = "[" + h + "]"
119 }
120 }
121 }
122
123 isVirtualStyle := c.isVirtualHostStyleRequest(targetURL, bucketName)
124
125 var urlStr string
126
127 if isVirtualStyle {
128 urlStr = c.endpointURL.Scheme + "://" + bucketName + "." + host + "/?session"
129 } else {
130 targetURL.Path = path.Join(bucketName, "") + "/"
131 targetURL.RawQuery = urlValues.Encode()
132 urlStr = targetURL.String()
133 }
134
135 // Get a new HTTP request for the method.
136 req, err := http.NewRequestWithContext(ctx, http.MethodGet, urlStr, nil)
137 if err != nil {
138 return nil, err
139 }
140
141 // Set UserAgent for the request.
142 c.setUserAgent(req)
143
144 // Get credentials from the configured credentials provider.
145 value, err := c.credsProvider.GetWithContext(c.CredContext())
146 if err != nil {
147 return nil, err
148 }
149
150 var (
151 signerType = value.SignerType
152 accessKeyID = value.AccessKeyID
153 secretAccessKey = value.SecretAccessKey
154 sessionToken = value.SessionToken
155 )
156
157 // Custom signer set then override the behavior.
158 if c.overrideSignerType != credentials.SignatureDefault {
159 signerType = c.overrideSignerType

Callers 1

CreateSessionMethod · 0.95

Calls 11

setUserAgentMethod · 0.95
CredContextMethod · 0.95
IsS3ExpressBucketFunction · 0.92
SignV4ExpressFunction · 0.92
getS3ExpressEndpointFunction · 0.85
GetWithContextMethod · 0.80
IsAnonymousMethod · 0.80
IsV2Method · 0.80
SetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected