Skip to content

Commit 5fc3150

Browse files
committed
Merge pull request git-lfs#215 from Mistobaan/feature/add-http-timeout
add default timeout to http client
2 parents 8dad4e8 + b4db8b6 commit 5fc3150

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lfs/http.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import (
66
"fmt"
77
"github.com/rubyist/tracerx"
88
"io"
9+
"net"
910
"net/http"
1011
"os"
1112
"strings"
13+
"time"
1214
)
1315

1416
func DoHTTP(c *Configuration, req *http.Request) (*http.Response, error) {
@@ -23,7 +25,14 @@ func DoHTTP(c *Configuration, req *http.Request) (*http.Response, error) {
2325

2426
func (c *Configuration) HttpClient() *http.Client {
2527
if c.httpClient == nil {
26-
tr := &http.Transport{}
28+
tr := &http.Transport{
29+
Proxy: http.ProxyFromEnvironment,
30+
Dial: (&net.Dialer{
31+
Timeout: 30 * time.Second,
32+
KeepAlive: 30 * time.Second,
33+
}).Dial,
34+
TLSHandshakeTimeout: 30 * time.Second,
35+
}
2736
sslVerify, _ := c.GitConfig("http.sslverify")
2837
if sslVerify == "false" || len(os.Getenv("GIT_SSL_NO_VERIFY")) > 0 {
2938
tr.TLSClientConfig = &tls.Config{InsecureSkipVerify: true}

0 commit comments

Comments
 (0)