Skip to content

Commit f72e32e

Browse files
committed
Fix posting payload
Cherrypicking: rakyll#285
1 parent ca8a616 commit f72e32e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎requester/requester.go‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ import (
3131
)
3232

3333
// Max size of the buffer of result channel.
34-
const maxResult = 1000000
35-
const maxIdleConn = 500
34+
const (
35+
maxResult = 1000000
36+
maxIdleConn = 500
37+
)
3638

3739
type result struct {
3840
err error
@@ -183,11 +185,12 @@ func (b *Work) makeRequest(c *http.Client) {
183185
}
184186
req = req.WithContext(httptrace.WithClientTrace(req.Context(), trace))
185187
resp, err := c.Do(req)
188+
req.Close = true
186189
if err == nil {
187190
size = resp.ContentLength
188191
code = resp.StatusCode
189192
io.Copy(ioutil.Discard, resp.Body)
190-
resp.Body.Close()
193+
defer resp.Body.Close()
191194
}
192195
t := now()
193196
resDuration = t - resStart

0 commit comments

Comments
 (0)