diff --git a/client/lib/lib.go b/client/lib/lib.go index c90e0ed..e4b756f 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -453,10 +453,6 @@ func GetServerHostname() string { return DefaultServerHostname } -func httpClient() *http.Client { - return &http.Client{} -} - func ApiGet(ctx context.Context, path string) ([]byte, error) { if os.Getenv("HISHTORY_SIMULATE_NETWORK_ERROR") != "" { return nil, fmt.Errorf("simulated network error: dial tcp: lookup api.hishtory.dev") @@ -469,7 +465,7 @@ func ApiGet(ctx context.Context, path string) ([]byte, error) { req.Header.Set("X-Hishtory-Version", "v0."+Version) req.Header.Set("X-Hishtory-Device-Id", hctx.GetConf(ctx).DeviceId) req.Header.Set("X-Hishtory-User-Id", data.UserId(hctx.GetConf(ctx).UserSecret)) - resp, err := httpClient().Do(req) + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, fmt.Errorf("failed to GET %s%s: %w", GetServerHostname(), path, err) } @@ -499,7 +495,7 @@ func ApiPost(ctx context.Context, path, contentType string, reqBody []byte) ([]b req.Header.Set("X-Hishtory-Version", "v0."+Version) req.Header.Set("X-Hishtory-Device-Id", hctx.GetConf(ctx).DeviceId) req.Header.Set("X-Hishtory-User-Id", data.UserId(hctx.GetConf(ctx).UserSecret)) - resp, err := httpClient().Do(req) + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, fmt.Errorf("failed to POST %s: %w", GetServerHostname()+path, err) } diff --git a/shared/ai/ai.go b/shared/ai/ai.go index 926b311..79208a8 100644 --- a/shared/ai/ai.go +++ b/shared/ai/ai.go @@ -68,7 +68,6 @@ func GetAiSuggestionsViaOpenAiApi(apiEndpoint, query, shellName, osName string, if apiKey == "" && apiEndpoint == DefaultOpenAiEndpoint { return nil, OpenAiUsage{}, fmt.Errorf("OPENAI_API_KEY environment variable is not set") } - client := &http.Client{} apiReq := openAiRequest{ Model: "gpt-3.5-turbo", NumberCompletions: numberCompletions, @@ -92,7 +91,7 @@ func GetAiSuggestionsViaOpenAiApi(apiEndpoint, query, shellName, osName string, if apiKey != "" { req.Header.Set("Authorization", "Bearer "+apiKey) } - resp, err := client.Do(req) + resp, err := http.DefaultClient.Do(req) if err != nil { return nil, OpenAiUsage{}, fmt.Errorf("failed to query OpenAI API: %w", err) }