fix(qbittorrent): recognize SID cookie from raw Set-Cookie header on login

qBittorrent (or its reverse proxy) was returning 204 No Content with an SID
cookie and no body on a successful login, but the client only treated the
response as success if body == "Ok." or the cookie was in the parsed
requests cookie jar (resp.cookies.get("SID")). In the reported case the
Set-Cookie header was present (set-cookie=yes) yet the jar was empty —
requests doesn't always populate the jar from such headers (proxy-set/oddly-
attributed cookies) — so a valid login was reported as "Unexpected response".
The user re-entering correct credentials never helped.

Detect a successful login from EITHER the parsed jar OR the raw Set-Cookie
header (cookie name == SID). qBittorrent only sets SID on a valid login, so
this remains authoritative. The diagnostic now lists the cookie names it saw
for future-proofing.

New regression test reproduces the exact 204 + Set-Cookie SID + empty jar
case. 387/387 backend tests pass; ruff clean.
This commit is contained in:
Developer
2026-07-12 10:52:31 +00:00
parent b9a79b85d1
commit 7e53edfcc6
4 changed files with 35 additions and 10 deletions
@@ -2,7 +2,7 @@
dir: backend/src/media_library_viewer_api/clients
## role
Collection of API and protocol client wrappers for external services (Jellyfin, Authentik, Jellyseerr, qBittorrent, SSH, local execution) with shared HTTP timeout configuration.
Provides external service integration clients for authenticating users and aggregating media, filesystem, and torrent data from APIs and remote/local hosts.
## parent
index: backend/src/media_library_viewer_api/.pi-map.index.md
map: backend/src/media_library_viewer_api/.pi-map.md