Skip to content

Commit 5424e22

Browse files
committed
use cli httpclient on board list command
1 parent ac92e32 commit 5424e22

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

commands/board/list.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
"regexp"
2424
"sync"
2525

26-
"github.com/arduino/arduino-cli/cli/globals"
2726
"github.com/arduino/arduino-cli/commands"
27+
"github.com/arduino/arduino-cli/httpclient"
2828
rpc "github.com/arduino/arduino-cli/rpc/commands"
2929
"github.com/pkg/errors"
3030
"github.com/segmentio/stats/v4"
@@ -51,12 +51,17 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
5151
url := fmt.Sprintf("%s/%s/%s", vidPidURL, vid, pid)
5252
retVal := []*rpc.BoardListItem{}
5353
req, _ := http.NewRequest("GET", url, nil)
54-
req.Header = globals.NewHTTPClientHeader("")
5554
req.Header.Set("Content-Type", "application/json")
5655

5756
// TODO: use proxy if set
5857

59-
if res, err := http.DefaultClient.Do(req); err == nil {
58+
httpClient, err := httpclient.New()
59+
60+
if err != nil {
61+
return nil, errors.Wrap(err, "failed to initialize http client")
62+
}
63+
64+
if res, err := httpClient.Do(req); err == nil {
6065
if res.StatusCode >= 400 {
6166
if res.StatusCode == 404 {
6267
return nil, ErrNotFound

0 commit comments

Comments
 (0)