diff --git a/component/http/http.go b/component/http/http.go index 2d709f54..d50eeb91 100644 --- a/component/http/http.go +++ b/component/http/http.go @@ -50,7 +50,7 @@ func HttpRequest(ctx context.Context, url, method string, header map[string][]st } } - if _, ok := req.Header["User-Agent"]; !ok { + if req.Header.Get("User-Agent") == "" { req.Header.Set("User-Agent", UA()) } diff --git a/transport/gun/gun.go b/transport/gun/gun.go index 7ca1f061..4d924530 100644 --- a/transport/gun/gun.go +++ b/transport/gun/gun.go @@ -351,7 +351,7 @@ func StreamGunWithTransport(transport *TransportWrap, cfg *Config) (net.Conn, er header := defaultHeader.Clone() if cfg.UserAgent != "" { - header["user-agent"] = []string{cfg.UserAgent} + header.Set("User-Agent", cfg.UserAgent) } request := &http.Request{