S065: custom download managers by name and port (D-050), D-022 JSON on 127.0.0.1:<port>, smoke case
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
parent
8386b32064
commit
e258b5b120
2 changed files with 310 additions and 38 deletions
|
|
@ -393,3 +393,49 @@ See `docs/FEATURES.md`; every row names the file that implements it and its revi
|
|||
to `Hub::blocked` (reset in the `load-changed` Started handler). Limits: depends on WebKit's console wording;
|
||||
WebKit may not log blocks for every load type (checked: script, image, fetch, module, async/defer, dynamic import);
|
||||
a block logged just after a new page starts may count for the new page.
|
||||
|
||||
## Custom download manager (D-022, D-050, S065)
|
||||
|
||||
Settings → Downloads → Download managers → "Add your own": a name and a port (1–65535, one entry per port).
|
||||
Stored as `downloads.custom_managers` (`[{name, port, enabled}]`); chosen in "New downloads go to" as
|
||||
`downloads.manager = "custom:<port>"`. Loopback only: the endpoint is always `http://127.0.0.1:<port>/` (no host
|
||||
field), so cookies never leave the machine and the VPN is never used (`net/dlm.rs`, `fetch::local_agent`).
|
||||
|
||||
- **Status ping**: `GET /`; any 2xx = "Found · port N", anything else = "Not running".
|
||||
- **Hand-over**: `POST /` with `Content-Type: application/json`; any 2xx = taken (the download shows as
|
||||
"Sent to <name>"); any other answer or no answer = Nacre downloads the file itself and the toast says why.
|
||||
|
||||
```http
|
||||
POST / HTTP/1.1
|
||||
Host: 127.0.0.1:8123
|
||||
Content-Type: application/json
|
||||
|
||||
{"url": "https://example.com/file.zip", "filename": "file.zip", "referrer": "https://example.com/",
|
||||
"cookies": "session=abc", "user_agent": "Mozilla/5.0 …",
|
||||
"headers": {"Cookie": "session=abc", "User-Agent": "Mozilla/5.0 …", "Referer": "https://example.com/"},
|
||||
"size": null, "mime": null}
|
||||
```
|
||||
|
||||
`cookies` is the Cookie header Nacre would send for that URL (empty when none); `headers` holds only the ones that
|
||||
are set; `size` and `mime` are null (not known before the download starts). A minimal receiver:
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
# Receives Nacre's downloads on 127.0.0.1:8123 and fetches them with curl.
|
||||
import json, subprocess
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self): # Nacre's status ping
|
||||
self.send_response(200); self.end_headers()
|
||||
|
||||
def do_POST(self): # a download handed over
|
||||
item = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
|
||||
args = ["curl", "-L", "-o", item["filename"] or "download", item["url"]]
|
||||
for name, value in item["headers"].items():
|
||||
args += ["-H", f"{name}: {value}"]
|
||||
subprocess.Popen(args)
|
||||
self.send_response(200); self.end_headers()
|
||||
|
||||
HTTPServer(("127.0.0.1", 8123), Handler).serve_forever()
|
||||
```
|
||||
|
|
|
|||
|
|
@ -515,6 +515,15 @@ Later: S010 list: user checks the Discord icon with their own client (the Discor
|
|||
- Verified: hidden `flyouts.txt` (needs `python3 -m http.server 8765 --directory tests/smoke/pages`) exit 0, shots read; `cargo test` 92 + webext 1.
|
||||
- Not done: favicons in flyout rows (icon only, as on the page); no visible run.
|
||||
|
||||
## S065 — Custom download manager by name and port (2026-11-18)
|
||||
- Done (D-050): Settings → Downloads → Download managers → "Add your own" (name + port, checked: name given, port 1–65535, one entry per port; the reason shows in the row); entries listed with "Found · port N" / "Not running", a switch and Remove; chosen in "New downloads go to" and the downloads flyout. Loopback only.
|
||||
- Settings: `downloads.custom_managers` = `[{name, port, enabled}]`, chosen as `downloads.manager = "custom:<port>"`. `net/dlm.rs`: `custom_key`, `is_on`, `label`, `enabled`, `parse_custom`, `custom_body`; ping = `GET http://127.0.0.1:<port>/`, hand-over = `POST /` with D-022's JSON (no token, D-050); fallback = Nacre downloads it, toast says why. Contract + example request + Python receiver: DESIGN.md "Custom download manager".
|
||||
- Smoke: `server.py` `POST /` records manager "custom" (port, Content-Type, body); `net-downloads.txt` custom case: handed over on 8767 (body checked in `/log`), fallback on port 9 → `file (3).zip`, `managers-custom` shot. Selftest `cmd ping_managers` (new).
|
||||
- Verified: `net-downloads.txt` exit 0 (also at 1400x2600, shot read); `cargo test` 94 + webext 1 (2 new dlm tests).
|
||||
- Not done: Add/Remove/switch not clicked in a smoke (set through settings JSON; the shot shows them).
|
||||
- Later: the managers page is wider than a 1280 px window (intro line and Port fields clipped at the right edge, seen in the 1280x800 shot; not from this plan).
|
||||
- Note: a stale `server.py` from an earlier session held port 8766; check `pgrep -f net/server.py` before starting one.
|
||||
|
||||
## Later
|
||||
- A link followed inside a frame still goes through the tab's navigation policy (WebKit's GTK API has no frame info; S050).
|
||||
- file:// media outside the XDG user folders doesn't play (WebKit sandbox, D-043).
|
||||
|
|
|
|||
Loading…
Reference in a new issue