Skip to content

Commit

Permalink
Merge pull request ethereum#67 from zama-ai/petar/http-close-body
Browse files Browse the repository at this point in the history
Close the HTTP response body from oracle DB
  • Loading branch information
dartdart26 authored Apr 12, 2023
2 parents 64bc5ba + 963c9ad commit aa44128
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions core/vm/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"math/big"
"net/http"
"os"
Expand Down Expand Up @@ -1355,14 +1355,12 @@ func verifyZkProof(input []byte) []byte {
if err != nil {
continue
}
// The ZKPoK service returns 406 if the proof is incorrect.
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if resp.StatusCode == 406 {
// The ZKPoK service returns 406 if the proof is incorrect.
return nil
} else if resp.StatusCode != 200 {
continue
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
} else if resp.StatusCode != 200 || err != nil {
continue
}
return body
Expand Down Expand Up @@ -1493,6 +1491,8 @@ func putRequire(ct *tfheCiphertext) bool {
if err != nil {
continue
}
defer resp.Body.Close()
io.ReadAll(resp.Body)
if resp.StatusCode != 200 {
continue
}
Expand All @@ -1516,11 +1516,9 @@ func getRequire(ct *tfheCiphertext) bool {
if err != nil {
continue
}
if resp.StatusCode != 200 {
continue
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if resp.StatusCode != 200 || err != nil {
continue
}
msg := requireMessage{}
Expand Down

0 comments on commit aa44128

Please sign in to comment.