]> Sergey Matveev's repositories - btrtrc.git/blobdiff - webseed/client.go
Drop support for go 1.20
[btrtrc.git] / webseed / client.go
index ce8e3a4296dffe15f08a1d2b2ac663ded3ec2486..ac42b8a427c3d6fe369f159e125611ffda434aa8 100644 (file)
@@ -11,6 +11,7 @@ import (
        "strings"
 
        "github.com/RoaringBitmap/roaring"
+
        "github.com/anacrolix/torrent/common"
        "github.com/anacrolix/torrent/metainfo"
        "github.com/anacrolix/torrent/segments"
@@ -41,11 +42,6 @@ func (r Request) Cancel() {
        r.cancel()
 }
 
-type Spec struct {
-       Urls      []string
-       EncodeUrl func(string) string
-}
-
 type Client struct {
        HttpClient *http.Client
        Url        string
@@ -57,7 +53,7 @@ type Client struct {
        // private in the future, if Client ever starts removing pieces.
        Pieces              roaring.Bitmap
        ResponseBodyWrapper ResponseBodyWrapper
-       EncodeUrl           func(string) string
+       PathEscaper         PathEscaper
 }
 
 type ResponseBodyWrapper func(io.Reader) io.Reader
@@ -82,9 +78,9 @@ func (ws *Client) NewRequest(r RequestSpec) Request {
        ctx, cancel := context.WithCancel(context.Background())
        var requestParts []requestPart
        if !ws.fileIndex.Locate(r, func(i int, e segments.Extent) bool {
-               req, err := NewRequestWithCustomUrlEncoding(
+               req, err := newRequest(
                        ws.Url, i, ws.info, e.Start, e.Length,
-                       ws.EncodeUrl,
+                       ws.PathEscaper,
                )
                if err != nil {
                        panic(err)