Skip to content

Commit

Permalink
lxd/devlxd: Avoid rendering prematurely
Browse files Browse the repository at this point in the history
The returned response will be rendered using the same `ResponseWriter` object, resulting on a redundant call to `WriteHeader` on the second Render call.

Signed-off-by: hamistao <[email protected]>
  • Loading branch information
hamistao committed Jan 8, 2025
1 parent 0ac5b83 commit 6b5f5c5
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions lxd/devlxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,7 @@ func devlxdImageExportHandler(d *Daemon, c instance.Instance, w http.ResponseWri
return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusForbidden, "not authorized"), c.Type() == instancetype.VM)
}

resp := imageExport(d, r)

err := resp.Render(w, r)
if err != nil {
return response.DevLxdErrorResponse(api.StatusErrorf(http.StatusInternalServerError, "internal server error"), c.Type() == instancetype.VM)
}

return response.DevLxdResponse(http.StatusOK, "", "raw", c.Type() == instancetype.VM)
return imageExport(d, r)
}

var devlxdMetadataGet = devLxdHandler{
Expand Down

0 comments on commit 6b5f5c5

Please sign in to comment.