5
5
"net"
6
6
"net/http"
7
7
"regexp"
8
+ "strconv"
8
9
"strings"
9
10
"sync"
10
11
"time"
@@ -22,14 +23,13 @@ type Client struct {
22
23
Credentials CredentialHelper
23
24
Netrc NetrcFinder
24
25
25
- DialTimeout int `git:"lfs.dialtimeout"`
26
- KeepaliveTimeout int `git:"lfs.keepalive"`
27
- TLSTimeout int `git:"lfs.tlstimeout"`
28
- ConcurrentTransfers int `git:"lfs.concurrenttransfers"`
29
-
30
- HTTPSProxy string
31
- HTTPProxy string
32
- NoProxy string
26
+ DialTimeout int
27
+ KeepaliveTimeout int
28
+ TLSTimeout int
29
+ ConcurrentTransfers int
30
+ HTTPSProxy string
31
+ HTTPProxy string
32
+ NoProxy string
33
33
34
34
hostClients map [string ]* http.Client
35
35
clientMu sync.Mutex
@@ -51,16 +51,22 @@ func NewClient(osEnv env, gitEnv env) (*Client, error) {
51
51
52
52
httpsProxy , httpProxy , noProxy := getProxyServers (osEnv , gitEnv )
53
53
54
- return & Client {
54
+ c := & Client {
55
55
Endpoints : NewEndpointFinder (gitEnv ),
56
56
Credentials : & CommandCredentialHelper {
57
57
SkipPrompt : ! osEnv .Bool ("GIT_TERMINAL_PROMPT" , true ),
58
58
},
59
- Netrc : netrc ,
60
- HTTPSProxy : httpsProxy ,
61
- HTTPProxy : httpProxy ,
62
- NoProxy : noProxy ,
63
- }, nil
59
+ Netrc : netrc ,
60
+ DialTimeout : gitEnv .Int ("lfs.dialtimeout" , 0 ),
61
+ KeepaliveTimeout : gitEnv .Int ("lfs.keepalive" , 0 ),
62
+ TLSTimeout : gitEnv .Int ("lfs.tlstimeout" , 0 ),
63
+ ConcurrentTransfers : gitEnv .Int ("lfs.concurrenttransfers" , 0 ),
64
+ HTTPSProxy : httpsProxy ,
65
+ HTTPProxy : httpProxy ,
66
+ NoProxy : noProxy ,
67
+ }
68
+
69
+ return c , nil
64
70
}
65
71
66
72
func (c * Client ) Do (req * http.Request ) (* http.Response , error ) {
@@ -170,6 +176,13 @@ func decodeResponse(res *http.Response, obj interface{}) error {
170
176
return nil
171
177
}
172
178
179
+ type env interface {
180
+ Get (string ) (string , bool )
181
+ Int (string , int ) int
182
+ Bool (string , bool ) bool
183
+ All () map [string ]string
184
+ }
185
+
173
186
// basic config.Environment implementation. Only used in tests, or as a zero
174
187
// value to NewClient().
175
188
type testEnv map [string ]string
@@ -179,6 +192,20 @@ func (e testEnv) Get(key string) (string, bool) {
179
192
return v , ok
180
193
}
181
194
195
+ func (e testEnv ) Int (key string , def int ) (val int ) {
196
+ s , _ := e .Get (key )
197
+ if len (s ) == 0 {
198
+ return def
199
+ }
200
+
201
+ i , err := strconv .Atoi (s )
202
+ if err != nil {
203
+ return def
204
+ }
205
+
206
+ return i
207
+ }
208
+
182
209
func (e testEnv ) Bool (key string , def bool ) (val bool ) {
183
210
s , _ := e .Get (key )
184
211
if len (s ) == 0 {
0 commit comments