check status code

This commit is contained in:
Mikaël Cluseau
2019-04-12 10:15:57 +01:00
parent 024fcdd35c
commit 201bca587e
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"io"
"log"
"net/http"
@ -39,6 +40,12 @@ func (ctx *renderContext) distFetch(path ...string) (outPath string, err error)
return
}
if resp.StatusCode != 200 {
err = fmt.Errorf("wrong status: %s", resp.Status)
resp.Body.Close()
return
}
tempOutPath := filepath.Join(filepath.Dir(outPath), "._part_"+filepath.Base(outPath))
done := make(chan error, 1)