all: cut bloated HTTP-client and tuning options

This is a personal torrent client, not a web client or daemon, so the
rarely-used HTTP-client knobs and redundant tuning flags are gone — flag,
config field, implementation, and tests removed for each. The option
surface drops from 54 to 28.

Web-client cluster removed: --all-proxy (HTTP_PROXY env still works),
load/save-cookies, --referer, -U/--user-agent, --http-user/--http-passwd,
--conditional-get, --remote-time, --check-certificate, --ca-certificate,
--lowest-speed-limit. Pass --header for a one-off auth/cookie/UA header.

Redundant knobs removed: -x and -k (folded into -s), --connect-timeout,
--retry-wait, per-item --max-download-limit/-u, --bt-max-peers,
--bt-stop-timeout, --disable-ipv6, --auto-save-interval, --human-readable,
--stop, -T (a positional .torrent works). follow-torrent and human-readable
are now unconditional defaults.
This commit is contained in:
2026-06-22 08:30:12 +09:00
parent 2afcb861e4
commit cf9082ff72
15 changed files with 157 additions and 1053 deletions

View File

@@ -78,7 +78,6 @@ func TestExitCode(t *testing.T) {
{"refused typed", refused, 6},
{"refused wrapped through retries", fmt.Errorf("http://x: %w (after 5 tries)", refused), 6},
{"not found", fmt.Errorf("%w: http://x/y: 404 Not Found", httpdl.ErrNotFound), 3},
{"too slow", fmt.Errorf("http://x: %w (<= %d bytes/sec)", httpdl.ErrTooSlow, 1024), 5},
{"checksum", fmt.Errorf("/tmp/x: %w (want a, got b)", httpdl.ErrChecksum), 32},
{"duplicate", fmt.Errorf("%w: same torrent as y", errDuplicate), 12},
{"unknown", errors.New("disk full"), 1},
@@ -104,7 +103,7 @@ func TestDedupeTorrents(t *testing.T) {
c := "magnet:?xt=urn:btih:1111111111111111111111111111111111111111&dn=other"
web := "http://example.com/file.iso"
dup := dedupeTorrents([]string{a, web, b, c}, true)
dup := dedupeTorrents([]string{a, web, b, c})
// b is the only duplicate (of a); a, web and c are not duplicates.
if len(dup) != 1 || dup[b] != a {
@@ -145,9 +144,8 @@ func TestGatherURIsGrouping(t *testing.T) {
}
// TestHTTPConnDefault locks the parallelism default: a bare `got URL` must use
// several connections, not one. With -x unset, --split drives the per-host
// connection count (capped at the -x ceiling of 16); an explicit -x is honored
// verbatim, including -x1 for a single connection.
// several connections, not one. --split is the single speed dial — it is the
// connection count directly, defaulting to 5.
func TestHTTPConnDefault(t *testing.T) {
cfg := func(args ...string) httpdl.Config {
res, err := cli.Parse(append([]string{"--no-conf"}, args...))
@@ -163,13 +161,11 @@ func TestHTTPConnDefault(t *testing.T) {
}{
{"bare URL uses split default", []string{"http://a/x"}, 5},
{"-s16 means 16", []string{"-s16", "http://a/x"}, 16},
{"-s100 capped at 16 per host", []string{"-s100", "http://a/x"}, 16},
{"explicit -x4 honored", []string{"-x4", "http://a/x"}, 4},
{"explicit -x1 stays single", []string{"-x1", "http://a/x"}, 1},
{"-s1 stays single", []string{"-s1", "http://a/x"}, 1},
}
for _, tc := range tests {
if c := cfg(tc.args...); c.MaxConnPerServer != tc.want {
t.Errorf("%s: MaxConnPerServer = %d, want %d", tc.name, c.MaxConnPerServer, tc.want)
if c := cfg(tc.args...); c.Split != tc.want {
t.Errorf("%s: Split = %d, want %d", tc.name, c.Split, tc.want)
}
}
}