|
1 | 1 | /* |
2 | 2 | * MinIO Go Library for Amazon S3 Compatible Cloud Storage |
3 | | - * Copyright 2015-2018 MinIO, Inc. |
| 3 | + * Copyright 2015-2023 MinIO, Inc. |
4 | 4 | * |
5 | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | * you may not use this file except in compliance with the License. |
@@ -29,6 +29,7 @@ import ( |
29 | 29 | "net" |
30 | 30 | "net/http" |
31 | 31 | "net/http/cookiejar" |
| 32 | + "net/http/httptrace" |
32 | 33 | "net/http/httputil" |
33 | 34 | "net/url" |
34 | 35 | "os" |
@@ -69,6 +70,7 @@ type Client struct { |
69 | 70 |
|
70 | 71 | // Needs allocation. |
71 | 72 | httpClient *http.Client |
| 73 | + httpTrace *httptrace.ClientTrace |
72 | 74 | bucketLocCache *bucketLocationCache |
73 | 75 |
|
74 | 76 | // Advanced functionality. |
@@ -103,6 +105,7 @@ type Options struct { |
103 | 105 | Creds *credentials.Credentials |
104 | 106 | Secure bool |
105 | 107 | Transport http.RoundTripper |
| 108 | + Trace *httptrace.ClientTrace |
106 | 109 | Region string |
107 | 110 | BucketLookup BucketLookupType |
108 | 111 |
|
@@ -229,6 +232,8 @@ func privateNew(endpoint string, opts *Options) (*Client, error) { |
229 | 232 | } |
230 | 233 | } |
231 | 234 |
|
| 235 | + clnt.httpTrace = opts.Trace |
| 236 | + |
232 | 237 | // Instantiate http client and bucket location cache. |
233 | 238 | clnt.httpClient = &http.Client{ |
234 | 239 | Jar: jar, |
@@ -771,6 +776,10 @@ func (c *Client) newRequest(ctx context.Context, method string, metadata request |
771 | 776 | return nil, err |
772 | 777 | } |
773 | 778 |
|
| 779 | + if c.httpTrace != nil { |
| 780 | + ctx = httptrace.WithClientTrace(ctx, c.httpTrace) |
| 781 | + } |
| 782 | + |
774 | 783 | // Initialize a new HTTP request for the method. |
775 | 784 | req, err = http.NewRequestWithContext(ctx, method, targetURL.String(), nil) |
776 | 785 | if err != nil { |
|
0 commit comments