From 445f92459b198f731850d2b5736bef7c3dcc663e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 2 Sep 2016 13:25:27 -0700 Subject: [PATCH] pixiecore: only close a non-nil body in API mode. Fixes #7. --- pixiecore/booters.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pixiecore/booters.go b/pixiecore/booters.go index cc860bd..da01a43 100644 --- a/pixiecore/booters.go +++ b/pixiecore/booters.go @@ -154,7 +154,9 @@ func (b *apibooter) getAPIResponse(hw net.HardwareAddr) (io.ReadCloser, error) { func (b *apibooter) BootSpec(m Machine) (*Spec, error) { body, err := b.getAPIResponse(m.MAC) - defer body.Close() + if body != nil { + defer body.Close() + } if err != nil { return nil, err }