Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
openstack: Don't close request bodies in handlers
Browse files Browse the repository at this point in the history
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 <mark.d.ryan@intel.com>
  • Loading branch information
Mark Ryan committed Oct 19, 2016
1 parent afad467 commit a8efaf8
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions openstack/image/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a8efaf8

Please sign in to comment.