Skip to content

Commit

Permalink
fix: unhandled error
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbekhen committed Aug 28, 2023
1 parent f54239b commit 4ae1a4e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ func (p *Proxy) handleHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusServiceUnavailable)
return
}
defer resp.Body.Close()
defer func(Body io.ReadCloser) {
_ = Body.Close()
}(resp.Body)

// copy all headers from the response to the client
copyHeader(w.Header(), resp.Header)
Expand All @@ -76,8 +78,10 @@ func (p *Proxy) handleHTTP(w http.ResponseWriter, r *http.Request) {

// transfer bytes from src to dst until either EOF is reached on src or an error occurs
func transfer(destination io.WriteCloser, source io.ReadCloser) {
defer destination.Close()
defer source.Close()
defer func() {
_ = destination.Close()
_ = source.Close()
}()
_, _ = io.Copy(destination, source)
}

Expand Down

0 comments on commit 4ae1a4e

Please sign in to comment.