system service: do not close Body

The standard lib states that server handlers don't need to close the
body, so let's not do that to avoid any unforeseen side effect.

[NO TESTS NEEDED] - existing tests should suffice.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-04-04 15:47:10 +02:00
parent e179079351
commit 1f3ae8a4fb
2 changed files with 0 additions and 3 deletions

View File

@ -895,7 +895,6 @@ func extractTarFile(r *http.Request) (string, error) {
// Content-Length not used as too many existing API clients didn't honor it
_, err = io.Copy(tarBall, r.Body)
r.Body.Close()
if err != nil {
return "", fmt.Errorf("failed Request: Unable to copy tar file from request body %s", r.RequestURI)
}

View File

@ -108,7 +108,6 @@ func KubePlay(w http.ResponseWriter, r *http.Request) {
options.Start = types.NewOptionalBool(query.Start)
}
report, err := containerEngine.PlayKube(r.Context(), r.Body, options)
_ = r.Body.Close()
if err != nil {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("playing YAML file: %w", err))
return
@ -132,7 +131,6 @@ func KubePlayDown(w http.ResponseWriter, r *http.Request) {
containerEngine := abi.ContainerEngine{Libpod: runtime}
report, err := containerEngine.PlayKubeDown(r.Context(), r.Body, entities.PlayKubeDownOptions{Force: query.Force})
_ = r.Body.Close()
if err != nil {
utils.Error(w, http.StatusInternalServerError, fmt.Errorf("tearing down YAML file: %w", err))
return