Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential resource leak by not closing the response body #14

Merged
merged 1 commit into from
Jan 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/go-camo/camo/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
mlog.Debugm("built outgoing request", mlog.Map{"req": nreq})

resp, err := p.client.Do(nreq)

if resp != nil {
defer resp.Body.Close()
}

if err != nil {
mlog.Debugm("could not connect to endpoint", mlog.Map{"err": err})
// this is a bit janky, but better than peeling off the
Expand All @@ -186,7 +191,6 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}
return
}
defer resp.Body.Close()

mlog.Debugm("response from upstream", mlog.Map{"resp": resp})

Expand Down