mirror of
https://github.com/jech/galene.git
synced 2024-11-09 02:05:59 +01:00
Discard response bodies in galenectl.
This commit is contained in:
parent
5557c07f1e
commit
991c0e1fc5
1 changed files with 5 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -366,6 +367,7 @@ func putJSON(url string, value any, overwrite bool) error {
|
|||
if resp.StatusCode >= 300 {
|
||||
return errors.New(resp.Status)
|
||||
}
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -391,6 +393,7 @@ func postJSON(url string, value any) (string, error) {
|
|||
return "", errors.New(resp.Status)
|
||||
}
|
||||
location := resp.Header.Get("location")
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
return location, nil
|
||||
}
|
||||
|
||||
|
@ -423,6 +426,7 @@ func updateJSON[T any](url string, update func(T) T) error {
|
|||
if resp.StatusCode >= 300 {
|
||||
return fmt.Errorf("%v %v", resp.StatusCode, resp.Status)
|
||||
}
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -440,6 +444,7 @@ func deleteValue(url string) error {
|
|||
if resp.StatusCode >= 300 {
|
||||
return fmt.Errorf("%v %v", resp.StatusCode, resp.Status)
|
||||
}
|
||||
io.Copy(io.Discard, resp.Body)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue