* Fix NPE

* bump version
This commit is contained in:
Shiming Zhang 2022-10-16 01:43:05 +08:00 committed by GitHub
parent 6f579d3ceb
commit 0005364363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 12 deletions

View File

@ -1 +1 @@
2.41
2.42

View File

@ -79,16 +79,18 @@ func checknosnat(w http.ResponseWriter, req *http.Request) {
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error querying %q, err: %v", url, err)
} else {
body, err := io.ReadAll(resp.Body)
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err)
} else {
// Respond the same status code and body as /checknosnat on the internal Pod
w.WriteHeader(resp.StatusCode)
w.Write(body)
}
return
}
resp.Body.Close()
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
w.WriteHeader(500)
fmt.Fprintf(w, "error reading body of response from %q, err: %v", url, err)
return
}
// Respond the same status code and body as /checknosnat on the internal Pod
w.WriteHeader(resp.StatusCode)
w.Write(body)
}