@@ -34,16 +34,9 @@ type client struct {
34
34
}
35
35
36
36
func NewClient (address string ) Client {
37
- // We cannot use the default transport because of a bug in go's connection reuse
38
- // code. It causes random failures in the connection including io.EOF and connection
39
- // refused on 'client.Do'
40
37
return & client {
41
38
serverAddress : address ,
42
- httpClient : & http.Client {
43
- Transport : & http.Transport {
44
- DisableKeepAlives : true ,
45
- },
46
- },
39
+ httpClient : http .DefaultClient ,
47
40
}
48
41
}
49
42
@@ -103,39 +96,27 @@ func (c *client) Send(req cmds.Request) (cmds.Response, error) {
103
96
version := config .CurrentVersionNumber
104
97
httpReq .Header .Set (uaHeader , fmt .Sprintf ("/go-ipfs/%s/" , version ))
105
98
106
- ec := make (chan error , 1 )
107
- rc := make (chan cmds.Response , 1 )
108
99
httpReq .Cancel = req .Context ().Done ()
100
+ httpReq .Close = true
109
101
110
- go func () {
111
- httpRes , err := c .httpClient .Do (httpReq )
112
- if err != nil {
113
- ec <- err
114
- return
115
- }
116
-
117
- // using the overridden JSON encoding in request
118
- res , err := getResponse (httpRes , req )
119
- if err != nil {
120
- ec <- err
121
- return
122
- }
123
-
124
- rc <- res
125
- }()
102
+ httpRes , err := c .httpClient .Do (httpReq )
103
+ if err != nil {
104
+ return nil , err
105
+ }
126
106
127
- select {
128
- case err := <- ec :
107
+ // using the overridden JSON encoding in request
108
+ res , err := getResponse (httpRes , req )
109
+ if err != nil {
129
110
return nil , err
130
- case res := <- rc :
131
- if found && len (previousUserProvidedEncoding ) > 0 {
132
- // reset to user provided encoding after sending request
133
- // NB: if user has provided an encoding but it is the empty string,
134
- // still leave it as JSON.
135
- req .SetOption (cmds .EncShort , previousUserProvidedEncoding )
136
- }
137
- return res , nil
138
111
}
112
+
113
+ if found && len (previousUserProvidedEncoding ) > 0 {
114
+ // reset to user provided encoding after sending request
115
+ // NB: if user has provided an encoding but it is the empty string,
116
+ // still leave it as JSON.
117
+ req .SetOption (cmds .EncShort , previousUserProvidedEncoding )
118
+ }
119
+ return res , nil
139
120
}
140
121
141
122
func getQuery (req cmds.Request ) (string , error ) {
0 commit comments