Skip to content

Commit 6ce72ca

Browse files
committed
PR feedback
1 parent c37dab3 commit 6ce72ca

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

client.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/base64"
88
"encoding/json"
99
"fmt"
10+
"net"
1011
"net/http"
1112
"net/url"
1213
"reflect"
@@ -30,6 +31,23 @@ var (
3031
contextType = reflect.TypeOf(new(context.Context)).Elem()
3132

3233
log = logging.Logger("rpc")
34+
35+
_defaultHTTPClient = &http.Client{
36+
Transport: &http.Transport{
37+
Proxy: http.ProxyFromEnvironment,
38+
DialContext: (&net.Dialer{
39+
Timeout: 30 * time.Second,
40+
KeepAlive: 30 * time.Second,
41+
DualStack: true,
42+
}).DialContext,
43+
ForceAttemptHTTP2: true,
44+
MaxIdleConns: 100,
45+
MaxIdleConnsPerHost: 100,
46+
IdleConnTimeout: 90 * time.Second,
47+
TLSHandshakeTimeout: 10 * time.Second,
48+
ExpectContinueTimeout: 1 * time.Second,
49+
},
50+
}
3351
)
3452

3553
// ErrClient is an error which occurred on the client side the library

options.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package jsonrpc
22

33
import (
4-
"net"
54
"net/http"
65
"reflect"
76
"time"
@@ -36,22 +35,7 @@ func defaultConfig() Config {
3635

3736
paramEncoders: map[reflect.Type]ParamEncoder{},
3837

39-
httpClient: &http.Client{
40-
Transport: &http.Transport{
41-
Proxy: http.ProxyFromEnvironment,
42-
DialContext: (&net.Dialer{
43-
Timeout: 30 * time.Second,
44-
KeepAlive: 30 * time.Second,
45-
DualStack: true,
46-
}).DialContext,
47-
ForceAttemptHTTP2: true,
48-
MaxIdleConns: 100,
49-
MaxIdleConnsPerHost: 100,
50-
IdleConnTimeout: 90 * time.Second,
51-
TLSHandshakeTimeout: 10 * time.Second,
52-
ExpectContinueTimeout: 1 * time.Second,
53-
},
54-
},
38+
httpClient: _defaultHTTPClient,
5539
}
5640
}
5741

0 commit comments

Comments
 (0)