X-Git-Url: http://www.git.cypherpunks.ru/?p=gocheese.git;a=blobdiff_plain;f=refresh.go;h=860267bfe620ca2abb2dc4bd9aac36288a967996;hp=625f840b5f3115b99b558f838f5d8953eddbc4be;hb=b461e610332c87d89aca09ad856a53a44f11c61b;hpb=0d804c602fbc55f58d04fa9657950f3a6aac6d81 diff --git a/refresh.go b/refresh.go index 625f840..860267b 100644 --- a/refresh.go +++ b/refresh.go @@ -60,6 +60,12 @@ func refreshDir( http.Error(w, err.Error(), http.StatusBadGateway) return false } + if resp.StatusCode != http.StatusOK { + resp.Body.Close() + log.Println("error", r.RemoteAddr, "refresh", pkgName, "HTTP status:", resp.Status) + http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway) + return false + } body, err := ioutil.ReadAll(resp.Body) resp.Body.Close() if err != nil { @@ -154,6 +160,15 @@ func refreshDir( return false } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + log.Println( + "error", r.RemoteAddr, + "pypi", filename, "download", + "HTTP status:", resp.Status, + ) + http.Error(w, "PyPI has non 200 status code", http.StatusBadGateway) + return false + } hasher := hasherNew() hasherSHA256 := sha256.New() dst, err := TempFile(dirPath)