funget
HTTP 文件传输工具,提供单线程下载、Range 并发下载、断点续传和 PUT/POST 上传。 核心由 Rust 实现,同时提供 Python 库和独立命令行二进制两种用法。
安装
作为 Python 库
pip install funget
需要 Python 3.12 或更高版本。无任何运行时依赖,各平台提供预编译 wheel, 安装时不需要 Rust 工具链。
只要命令行
命令行是独立的原生二进制,不需要 Python 环境。从 Releases 下载对应平台的文件即可:
curl -L https://github.com/farfarfun/funget/releases/latest/download/funget-x86_64-unknown-linux-gnu -o funget
chmod +x funget && sudo mv funget /usr/local/bin/
有 Rust 工具链的话也可以 cargo install funget。
pip install funget 同样会提供 funget 命令,三条渠道共用同一套实现,
funget --version 报同一个版本号。
作为 Rust 库
下载/上传引擎本身发布在 crates.io 上,可以脱离 Python 和 CLI 单独使用:
[dependencies]
funget-core = "0.2"
crate 的版本线是独立的 0.x —— 它的公开模块当初是为跨 crate 复用而 pub 的,
不是按公共 Rust API 设计的,所以在 0.x 期间仍会调整。详见
crates/funget-core/README.md。
命令行
funget download https://httpbin.org/bytes/1024 -o file.bin
funget download https://httpbin.org/bytes/1024 --worker 8 --block-size 50
funget download https://httpbin.org/bytes/1024 -o file.bin --resume # 中断后重跑继续
funget upload ./file.bin https://httpbin.org/put
funget info https://httpbin.org/bytes/1024
download、upload、info 三个子命令共用一组 HTTP 开关,短选项与 curl 对齐:
| 开关 | 说明 |
|---|---|
-H, --header LINE |
追加请求头,格式 Name: value,可重复 |
-u, --user USER:PASSWORD |
Basic 认证。按第一个冒号切分,-u user: 是空密码 |
-A, --user-agent NAME |
覆盖默认的 funget/<版本号> |
--timeout SECONDS |
连接与读取超时。download 默认 30,upload 默认 60 |
-x, --proxy URL |
支持 http://、https://、socks5://、socks5h:// |
-k, --insecure |
接受无效证书(含主机名不匹配) |
--cacert FILE |
追加信任的 PEM 证书,可重复;一个文件里放整条证书链也可以 |
--no-native-certs |
不读系统证书库,只用内置的 webpki 根证书 |
--no-location |
不跟随重定向。funget 默认跟随,所以这里是反向开关(curl 是正向的 -L) |
--max-redirs N |
最多跟随多少跳,默认 10 |
download 和 upload 另有 -s, --silent 关掉进度条(非 TTY 环境本来就不画)。
不传 -x 时沿用 HTTP_PROXY / HTTPS_PROXY / NO_PROXY 环境变量,与 curl 一致。
运行 funget --help 或 funget <command> --help 查看完整参数。
证书
TLS 信任的是内置 webpki 根证书与系统证书库的并集,所以企业私有 CA、内网自签
证书这类场景只要机器上装好了就能直接用。极少数机器的系统证书库 rustls 一张都解析
不了(截断过的 ca-certificates bundle 等),客户端会构造失败,用
--no-native-certs 退回只用内置根证书。
Python API
download() 会先检查文件大小和 Range 支持:超过 10 MiB 且服务器支持 Range 时并发下载,否则使用单线程。
from funget import download
ok = download(
"https://httpbin.org/bytes/1024",
"./downloads/file.bin",
overwrite=True,
)
也可以显式选择下载方式:
from funget import multi_thread_download, simple_download
simple_download(
"https://httpbin.org/bytes/1024", "./downloads/small.bin", chunk_size=64 * 1024
)
multi_thread_download(
"https://httpbin.org/bytes/1024",
"./downloads/large.bin",
worker_num=8,
block_size=50,
)
上传支持 PUT 和 multipart POST:
from pathlib import Path
from tempfile import TemporaryDirectory
from funget import single_upload
with TemporaryDirectory() as directory:
filepath = Path(directory) / "example-upload.txt"
filepath.write_text("funget upload example\n", encoding="utf-8")
single_upload("https://httpbin.org/put", str(filepath), method="PUT")
single_upload("https://httpbin.org/post", str(filepath), method="POST")
该示例使用公开测试服务,运行时需要网络连接。生产环境请使用接受相应
PUT 或 multipart POST 请求的上传地址。
断点续传
传 resume=True 后,中断的下载在下次调用时从断点继续,单线程和并发两条路径都支持:
from funget import download
download("https://example.com/huge.iso", "./huge.iso", resume=True)
续传期间会在目标文件旁维护 huge.iso.funget.json 状态文件,下载成功后自动删除。
远端文件若发生变化(ETag、Last-Modified 或大小不匹配),续传状态会被丢弃并重新下载,
不会拼出一个损坏的文件。默认关闭,不开启时行为与旧版完全一致。
参数
所有公开 API 均返回 bool,不抛异常。常用参数:
| 参数 | 单位 | 说明 |
|---|---|---|
worker_num |
个 | 并发下载的分块并发数 |
block_size |
MiB | 多线程下载分块大小 |
chunk_size |
字节 | 单线程下载或上传读取块大小 |
max_retries |
次 | 失败后的最大重试次数,退避 2^n 秒 |
timeout |
秒 | 单次读取超时(不是整体下载超时) |
headers |
- | 自定义 HTTP 请求头 |
auth |
- | (用户名, 密码) 二元组,走 Basic 认证 |
resume |
- | 是否启用断点续传,默认 False |
filesize |
字节 | 已知文件大小,传了就跳过 HEAD 探测 |
insecure |
- | 接受无效证书,默认 False。对应 CLI 的 -k |
cacert |
- | 追加信任的 PEM 证书路径,对应 CLI 的 --cacert |
proxy |
- | 代理地址,不传则读 HTTP_PROXY / HTTPS_PROXY / NO_PROXY |
insecure、cacert、proxy 与 resume、filesize 一样只能按关键字传
(keyword-only)—— 原有签名是冻结的,新能力一律往后追加。完整签名见
src/funget/__init__.pyi。
重定向默认跟随,最多 10 跳;Python 侧不开放这两个旋钮,CLI 的 --no-location /
--max-redirs 是排障用的。
关于 farfarfun
farfarfun 是一个专注于实用工具库的开源组织, 涵盖云存储、数据处理、AI、多媒体与开发工具链等方向。
- 🏠 组织主页:https://github.com/farfarfun
- 📦 PyPI:https://pypi.org/user/niuliangtao/
- 📧 联系:farfarfun@qq.com
本项目基于 MIT 协议开源。
Metadata
Release files for funget 1.1.72
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| funget-1.1.72.tar.gz | 80.5 kB | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| funget-1.1.72-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| funget-1.1.72-cp312-abi3-musllinux_1_2_x86_64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ x86-64 | Details |
| funget-1.1.72-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| funget-1.1.72-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| funget-1.1.72-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
| funget-1.1.72-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 13.0 MB
Release files / funget-1.1.72.tar.gz
| Download URL | funget-1.1.72.tar.gz |
|---|---|
| Size | 80.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a483e484c169ab9f1b9518c3e6f3fb3b5ed3348780691ca1f7793a380e1c475a
|
|
BLAKE2b-256 checksum How to use checksums |
9c3fe03ce2c902ffae9701f6ff93f5777b7cc37e9f277a97e60df81c4c3fafe7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-win_amd64.whl
| Download URL | funget-1.1.72-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
44b177f82ecfe7aa99d0286e507c9a8eaeb1ee26a1ce09610641c4c5715e6269
|
|
BLAKE2b-256 checksum How to use checksums |
911c3b7516bb08b6f9842389099abb2d6d9f88f45b74b39f743d302bbeacaab5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | funget-1.1.72-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4656366cf3e0070d5ed36ad4faf2be1e3bf9245a1e2df70aa644a194e73bb9c4
|
|
BLAKE2b-256 checksum How to use checksums |
7e037140ad73c2861793ecdc844d73d5c98697143ed0a7728db40d9fd60dc489
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | funget-1.1.72-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
058d3fe39d5e772ac938fc81109213671d3e40b1dea1fe1a63b239a095871146
|
|
BLAKE2b-256 checksum How to use checksums |
503726c472f71a585640b9f33bf7bd80bd678a18bc45cd33464e9057831f9b44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | funget-1.1.72-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
a5f8212ed55c2818bcbc82c5777c8025bc4689a53778e46fe92d39c10959ad60
|
|
BLAKE2b-256 checksum How to use checksums |
b3d206344683bf3daed7a3643885e80f55c0501081e3ae779bfa3679258f21fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | funget-1.1.72-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
36a95caefc056b458e3cdde2e35fb5ec29cc3be530e4183187fb9a39e951e47d
|
|
BLAKE2b-256 checksum How to use checksums |
6199e98207e560245edc76dffd98e5bd8a22f3e49f71d5f042b1b01e085f0801
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / funget-1.1.72-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | funget-1.1.72-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1c81b4c6ebce5190da7ac9640566b1e3d7c5043c6e88423cc892ff5e5afe7c30
|
|
BLAKE2b-256 checksum How to use checksums |
1cd2960574e8504ba6e4f0e38410e4c9c9587655e63fd5fadb401071f346bac0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|