]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Expect 200 OK in torrent source response
authorMatt Joiner <anacrolix@gmail.com>
Fri, 25 Feb 2022 08:52:23 +0000 (19:52 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Fri, 25 Feb 2022 08:59:16 +0000 (19:59 +1100)
sources.go

index 46c6abe9f9d8b3e7c745dd7de73112fdee39dc28..4fd44673e41b2cc0c5e0ae2122dbef43db17c7e7 100644 (file)
@@ -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
 }