commit 63d622e14a6b1db8e7fb9fb47ee745355b297894
parent fd6295cc21bb5dc611d469a3d6247362a2993e73
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 30 Jan 2023 16:29:20 -0800
close http body & handle errors
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/cmd/dkfupload/main.go b/cmd/dkfupload/main.go
@@ -103,10 +103,14 @@ func main() {
req, _ := http.NewRequest(http.MethodPost, baseUrl+"/file-drop/"+filedropUUID, nil)
req.Header.Set("User-Agent", userAgent)
req.Header.Set("DKF_API_KEY", apiKey)
- _, err := client.Do(req)
+ resp, err := client.Do(req)
if err != nil {
return err
}
+ defer resp.Body.Close()
+ if resp.StatusCode != http.StatusOK {
+ return fmt.Errorf("invalid status code %s", resp.Status)
+ }
return nil
})
}