Documentation
¶
Index ¶
Constants ¶
const MaxDiscardBytes = 48 << 10
How many consecutive bytes to allow discarding from responses. This number is based on https://archive.org/download/BloodyPitOfHorror/BloodyPitOfHorror.asr.srt. It seems that archive.org might be using a webserver implementation that refuses to do partial responses to small files. TODO: Make this configurable.
Variables ¶
var ErrTooFast = errors.New("making requests too fast")
var PrintDebug = false
Output debug information to stdout.
Functions ¶
func EscapePath ¶
Escapes path name components suitable for appending to a webseed URL. This works for converting S3 object keys to URLs too.
Contrary to the name, this actually does a QueryEscape, rather than a PathEscape. This works better with most S3 providers.
Types ¶
type Client ¶
type Client struct {
Logger *slog.Logger
HttpClient *http.Client
Url string
// Max concurrent requests to a WebSeed for a given torrent. TODO: Unused.
MaxRequests int
// The pieces we can request with the Url. We're more likely to ban/block at the file-level
// given that's how requests are mapped to webseeds, but the torrent.Client works at the piece
// level. We can map our file-level adjustments to the pieces here. This probably need to be
// private in the future, if Client ever starts removing pieces. TODO: This belongs in
// webseedPeer. TODO: Unused.
Pieces roaring.Bitmap
// This wraps http.Response bodies, for example to limit the download rate.
ResponseBodyWrapper ResponseBodyWrapper
ResponseBodyRateLimiter *rate.Limiter
PathEscaper PathEscaper
// contains filtered or unexported fields
}
func (*Client) StartNewRequest ¶
func (*Client) UrlForFileIndex ¶
Returns the URL for the given file index. This is assumed to be globally unique.
type ErrBadResponse ¶
func (ErrBadResponse) Error ¶
func (me ErrBadResponse) Error() string
type ErrStatusOkForRangeRequest ¶
type ErrStatusOkForRangeRequest struct{}
func (ErrStatusOkForRangeRequest) Error ¶
func (ErrStatusOkForRangeRequest) Error() string
type PathEscaper ¶
type ReadRequestPartError ¶
Contains info for callers to act (like ignoring particular files or rate limiting).
func (ReadRequestPartError) Error ¶
func (r ReadRequestPartError) Error() string
func (ReadRequestPartError) Unwrap ¶
func (me ReadRequestPartError) Unwrap() error