From a8efaf8a8fc94be8182890fa8ac595b1425a20d2 Mon Sep 17 00:00:00 2001 From: Mark Ryan Date: Wed, 19 Oct 2016 16:41:31 +0100 Subject: [PATCH] openstack: Don't close request bodies in handlers The image service code seems to be closing the bodies of received requests in its handlers. This breaks in Go 1.8 as these bodies are likely to be nil. Also, unless I'm mistaken, there's no need for the server to close the bodies. This is only needed for clients that pass a file or a socket to http.NewRequest. Signed-off-by: Mark Ryan --- openstack/image/api.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/openstack/image/api.go b/openstack/image/api.go index 437ff9e5f..5b1907184 100644 --- a/openstack/image/api.go +++ b/openstack/image/api.go @@ -367,8 +367,6 @@ func getImage(context *Context, w http.ResponseWriter, r *http.Request) (APIResp vars := mux.Vars(r) imageID := vars["image_id"] - defer r.Body.Close() - resp, err := context.GetImage(imageID) if err != nil { return errorResponse(err), err @@ -380,8 +378,6 @@ func uploadImage(context *Context, w http.ResponseWriter, r *http.Request) (APIR vars := mux.Vars(r) imageID := vars["image_id"] - defer r.Body.Close() - _, err := context.UploadImage(imageID, r.Body) if err != nil { return errorResponse(err), err @@ -393,8 +389,6 @@ func deleteImage(context *Context, w http.ResponseWriter, r *http.Request) (APIR vars := mux.Vars(r) imageID := vars["image_id"] - defer r.Body.Close() - _, err := context.DeleteImage(imageID) if err != nil { return errorResponse(err), err