Skip to content

Commit 01718c1

Browse files
committed
Don't use default http client
1 parent 6f33679 commit 01718c1

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

tests/framework/request.go

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ func makeRequest(
5656
) (*http.Response, error) {
5757
dialer := &net.Dialer{}
5858

59-
baseTransport, ok := http.DefaultTransport.(*http.Transport)
59+
transport, ok := http.DefaultTransport.(*http.Transport)
6060
if !ok {
6161
return nil, errors.New("transport is not of type *http.Transport")
6262
}
6363

64-
customTransport := baseTransport.Clone()
64+
customTransport := transport.Clone()
6565
customTransport.DialContext = func(
6666
ctx context.Context,
6767
network,
@@ -94,21 +94,13 @@ func makeRequest(
9494

9595
var resp *http.Response
9696
if strings.HasPrefix(url, "https") {
97-
transport, ok := http.DefaultTransport.(*http.Transport)
98-
if !ok {
99-
return nil, errors.New("transport is not of type *http.Transport")
100-
}
101-
102-
customTransport := transport.Clone()
10397
// similar to how in our examples with https requests we run our curl command
10498
// we turn off verification of the certificate, we do the same here
10599
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} //nolint:gosec // for https test traffic
106-
client := &http.Client{Transport: customTransport}
107-
resp, err = client.Do(req)
108-
} else {
109-
resp, err = http.DefaultClient.Do(req)
110100
}
111101

102+
client := &http.Client{Transport: customTransport}
103+
resp, err = client.Do(req)
112104
if err != nil {
113105
return nil, err
114106
}

0 commit comments

Comments
 (0)