Skip to content

Commit ac92e32

Browse files
committed
set downloader user-agent tp equal cli httpclient
1 parent e5bdd84 commit ac92e32

File tree

2 files changed

+5
-20
lines changed

2 files changed

+5
-20
lines changed

cli/globals/globals.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616
package globals
1717

1818
import (
19-
"fmt"
20-
"net/http"
2119
"os"
2220
"path/filepath"
23-
"runtime"
2421

2522
"github.com/arduino/arduino-cli/version"
2623
)
@@ -31,18 +28,3 @@ var (
3128
// DefaultIndexURL is the default index url
3229
DefaultIndexURL = "https://downloads.arduino.cc/packages/package_index.json"
3330
)
34-
35-
// NewHTTPClientHeader returns the http.Header object that must be used by the clients inside the downloaders
36-
// and adds the subComponent if specified
37-
func NewHTTPClientHeader(subComponent string) http.Header {
38-
if subComponent != "" {
39-
subComponent = " " + subComponent
40-
}
41-
userAgentValue := fmt.Sprintf("%s/%s%s (%s; %s; %s) Commit:%s",
42-
VersionInfo.Application,
43-
VersionInfo.VersionString,
44-
subComponent,
45-
runtime.GOARCH, runtime.GOOS, runtime.Version(),
46-
VersionInfo.Commit)
47-
return http.Header{"User-Agent": []string{userAgentValue}}
48-
}

commands/download.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
package commands
1717

1818
import (
19+
"net/http"
1920
"net/url"
2021
"time"
2122

22-
"github.com/arduino/arduino-cli/cli/globals"
23+
"github.com/arduino/arduino-cli/httpclient"
2324
rpc "github.com/arduino/arduino-cli/rpc/commands"
2425
"github.com/pkg/errors"
2526
"github.com/sirupsen/logrus"
@@ -31,7 +32,9 @@ import (
3132
// current settings.
3233
func GetDownloaderConfig() (*downloader.Config, error) {
3334
res := &downloader.Config{
34-
RequestHeaders: globals.NewHTTPClientHeader(viper.GetString("network.user_agent_ext")),
35+
RequestHeaders: http.Header{
36+
"User-Agent": []string{httpclient.UserAgent()},
37+
},
3538
}
3639
if viper.IsSet("network.proxy") {
3740
proxy := viper.GetString("network.proxy")

0 commit comments

Comments
 (0)