From: Matt Joiner Date: Fri, 25 Feb 2022 08:52:23 +0000 (+1100) Subject: Expect 200 OK in torrent source response X-Git-Tag: v1.42.0~14^2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=6e760a6210a5d57acc73d9591e48edc0c0a08352;p=btrtrc.git Expect 200 OK in torrent source response --- diff --git a/sources.go b/sources.go index 46c6abe9..4fd44673 100644 --- a/sources.go +++ b/sources.go @@ -2,6 +2,7 @@ package torrent import ( "context" + "fmt" "net/http" "github.com/anacrolix/log" @@ -66,6 +67,10 @@ func getTorrentSource(ctx context.Context, source string, hc *http.Client) (mi m return } defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + err = fmt.Errorf("unexpected response status code: %v", resp.StatusCode) + return + } err = bencode.NewDecoder(resp.Body).Decode(&mi) return }