Skip to content

Commit 89aeb92

Browse files
committed
I now ensure unsupported http client options log a fatal error
1 parent 5420467 commit 89aeb92

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

clicommand/agent_start.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,12 @@ var AgentStartCommand = cli.Command{
11041104

11051105
l.Info("Using http client profile: %s", cfg.HTTPClientProfile)
11061106

1107-
if !slices.Contains(agenthttp.ValidHTTPClientProfiles, cfg.HTTPClientProfile) {
1108-
l.Fatal("HTTP client profile %s is not in list of valid profiles: %v", cfg.HTTPClientProfile, agenthttp.ValidHTTPClientProfiles)
1107+
if !slices.Contains(agenthttp.ValidClientProfiles, cfg.HTTPClientProfile) {
1108+
l.Fatal("HTTP client profile %s is not in list of valid profiles: %v", cfg.HTTPClientProfile, agenthttp.ValidClientProfiles)
1109+
}
1110+
1111+
if cfg.HTTPClientProfile == agenthttp.ClientProfileStdlib && cfg.NoHTTP2 {
1112+
l.Fatal("NoHTTP2 is not supported with the standard library (%s) HTTP client profile, use GODEBUG see https://pkg.go.dev/net/http#hdr-HTTP_2", agenthttp.ClientProfileStdlib)
11091113
}
11101114

11111115
if len(cfg.AllowedRepositories) > 0 {

internal/agenthttp/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ import (
1212
)
1313

1414
var (
15+
ClientProfileDefault = "default"
16+
ClientProfileStdlib = "stdlib"
17+
1518
// ValidHTTPClientProfiles lists accepted values for Config.HTTPClientProfile.
16-
ValidHTTPClientProfiles = []string{"stdlib", "default"}
19+
ValidClientProfiles = []string{ClientProfileDefault, ClientProfileStdlib}
1720
)
1821

1922
// NewClient creates a HTTP client. Note that the default timeout is 60 seconds;
@@ -34,7 +37,7 @@ func NewClient(opts ...ClientOption) *http.Client {
3437
// http client profile is used to switch between different http client implementations
3538
// - stdlib: uses the standard library http client
3639
switch conf.HTTPClientProfile {
37-
case "stdlib":
40+
case ClientProfileStdlib:
3841
// Base any modifications on the default transport.
3942
transport := http.DefaultTransport.(*http.Transport).Clone()
4043

0 commit comments

Comments
 (0)