Commit 991c0e1f authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Discard response bodies in galenectl.

parent 5557c07f
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"io"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
...@@ -366,6 +367,7 @@ func putJSON(url string, value any, overwrite bool) error { ...@@ -366,6 +367,7 @@ func putJSON(url string, value any, overwrite bool) error {
if resp.StatusCode >= 300 { if resp.StatusCode >= 300 {
return errors.New(resp.Status) return errors.New(resp.Status)
} }
io.Copy(io.Discard, resp.Body)
return nil return nil
} }
...@@ -391,6 +393,7 @@ func postJSON(url string, value any) (string, error) { ...@@ -391,6 +393,7 @@ func postJSON(url string, value any) (string, error) {
return "", errors.New(resp.Status) return "", errors.New(resp.Status)
} }
location := resp.Header.Get("location") location := resp.Header.Get("location")
io.Copy(io.Discard, resp.Body)
return location, nil return location, nil
} }
...@@ -423,6 +426,7 @@ func updateJSON[T any](url string, update func(T) T) error { ...@@ -423,6 +426,7 @@ func updateJSON[T any](url string, update func(T) T) error {
if resp.StatusCode >= 300 { if resp.StatusCode >= 300 {
return fmt.Errorf("%v %v", resp.StatusCode, resp.Status) return fmt.Errorf("%v %v", resp.StatusCode, resp.Status)
} }
io.Copy(io.Discard, resp.Body)
return nil return nil
} }
...@@ -440,6 +444,7 @@ func deleteValue(url string) error { ...@@ -440,6 +444,7 @@ func deleteValue(url string) error {
if resp.StatusCode >= 300 { if resp.StatusCode >= 300 {
return fmt.Errorf("%v %v", resp.StatusCode, resp.Status) return fmt.Errorf("%v %v", resp.StatusCode, resp.Status)
} }
io.Copy(io.Discard, resp.Body)
return nil return nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment