Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit c91cf6e

Browse files
authored
Merge pull request #103 from kochd/pow
Properly close socket connections
2 parents bdfde84 + 03ad238 commit c91cf6e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

client/uploader_http_pow.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func (u *httpUploaderPow) getPow(target interface{}) {
5252
log.Errorf("Error in Pow Get request: %v", err)
5353
return
5454
}
55+
defer resp.Body.Close()
5556

5657
if resp.StatusCode != 200 {
5758
log.Errorf("Got bad response code: %v", resp.StatusCode)
5859
return
5960
}
6061

61-
defer resp.Body.Close()
6262
json.NewDecoder(resp.Body).Decode(target)
6363
if err != nil {
6464
log.Errorf("Error in parsing Pow Get request: %v", err)
@@ -78,6 +78,7 @@ func (u *httpUploaderPow) uploadWithPow(pow Pow, solution string, natsmsg []byte
7878
"solution": {solution},
7979
"natsmsg": {string(natsmsg)},
8080
})
81+
defer resp.Body.Close()
8182

8283
if err != nil {
8384
log.Errorf("Error while prooving pow: %v", err)

0 commit comments

Comments
 (0)