Read about our upcoming Code of Conduct on this issue

Commit 8500146e authored by feistel's avatar feistel
Browse files

refactor: update usage of NewHTTPClient to NewHTTPClientWithOpts

parent 6ea629933069
......@@ -59,7 +59,8 @@
secret := "sssh, it's a secret"
httpClient := NewHTTPClient(url, tc.relativeURLRoot, tc.caFile, "", false, 1)
httpClient, err := NewHTTPClientWithOpts(url, tc.relativeURLRoot, tc.caFile, "", false, 1, nil)
require.NoError(t, err)
client, err := NewGitlabNetClient("", "", secret, httpClient)
require.NoError(t, err)
......
......@@ -17,7 +17,8 @@
func TestReadTimeout(t *testing.T) {
expectedSeconds := uint64(300)
client := NewHTTPClient("http://localhost:3000", "", "", "", false, expectedSeconds)
client, err := NewHTTPClientWithOpts("http://localhost:3000", "", "", "", false, expectedSeconds, nil)
require.NoError(t, err)
require.NotNil(t, client)
require.Equal(t, time.Duration(expectedSeconds)*time.Second, client.Client.Timeout)
......@@ -122,7 +123,8 @@
func setup(t *testing.T, username, password string, requests []testserver.TestRequestHandler) *GitlabNetClient {
url := testserver.StartHttpServer(t, requests)
httpClient := NewHTTPClient(url, "", "", "", false, 1)
httpClient, err := NewHTTPClientWithOpts(url, "", "", "", false, 1, nil)
require.NoError(t, err)
client, err := NewGitlabNetClient(username, password, "", httpClient)
require.NoError(t, err)
......
......@@ -15,6 +15,7 @@
"gitlab.com/gitlab-org/gitlab-shell/client"
"gitlab.com/gitlab-org/gitlab-shell/internal/metrics"
"gitlab.com/gitlab-org/labkit/log"
)
const (
......@@ -97,10 +98,10 @@
func (c *Config) HttpClient() *client.HttpClient {
c.httpClientOnce.Do(func() {
client := client.NewHTTPClient(
client, err := client.NewHTTPClientWithOpts(
c.GitlabUrl,
c.GitlabRelativeURLRoot,
c.HttpSettings.CaFile,
c.HttpSettings.CaPath,
c.HttpSettings.SelfSignedCert,
c.HttpSettings.ReadTimeoutSeconds,
......@@ -101,7 +102,8 @@
c.GitlabUrl,
c.GitlabRelativeURLRoot,
c.HttpSettings.CaFile,
c.HttpSettings.CaPath,
c.HttpSettings.SelfSignedCert,
c.HttpSettings.ReadTimeoutSeconds,
nil,
)
......@@ -107,4 +109,7 @@
)
if err != nil {
log.WithError(err).Fatal("new http client with opts")
}
tr := client.Transport
client.Transport = promhttp.InstrumentRoundTripperDuration(metrics.HttpRequestDuration, tr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment