CLI checks for HTTP 401
The CLI doesn't yet support passing authentication credentials, but this change means the user will know what is happening.
@@ -133,6 +133,10 @@ func sendRequest(ctx *cli.Context, urlStr string, line string, argv *argT, ret i
}
defer resp.Body.Close()
+ if resp.StatusCode == http.StatusUnauthorized {
+ return fmt.Errorf("unauthorized")
+ }
+
// Check for redirect.
if resp.StatusCode == http.StatusMovedPermanently {
nRedirect++
@@ -190,6 +194,10 @@ func cliJSON(ctx *cli.Context, cmd, line, url string, argv *argT) error {
}
defer resp.Body.Close()
+ if resp.StatusCode == http.StatusUnauthorized {
+ return fmt.Errorf("unauthorized")
+ }
+
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
