Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit b683f18

Browse files
committed
add option to specify http client on shell creation
1 parent 7af57c8 commit b683f18

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

shell.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ type Shell struct {
2525
}
2626

2727
func NewShell(url string) *Shell {
28+
c := &gohttp.Client{
29+
Transport: &gohttp.Transport{
30+
DisableKeepAlives: true,
31+
},
32+
}
33+
34+
return NewShellWithClient(url, c)
35+
}
36+
37+
func NewShellWithClient(url string, c *gohttp.Client) *Shell {
2838
if a, err := ma.NewMultiaddr(url); err == nil {
2939
_, host, err := manet.DialArgs(a)
3040
if err == nil {
@@ -33,12 +43,8 @@ func NewShell(url string) *Shell {
3343
}
3444

3545
return &Shell{
36-
url: url,
37-
httpcli: &gohttp.Client{
38-
Transport: &gohttp.Transport{
39-
DisableKeepAlives: true,
40-
},
41-
},
46+
url: url,
47+
httpcli: c,
4248
}
4349
}
4450

0 commit comments

Comments
 (0)