This pull request improves the robustness and reliability of the DownloadService by enhancing HTTP client handling and defensive error checking for all supported download clients (qBittorrent, Transmission, SABnzbd, NZBGet). The main changes include switching to local HttpClient instances with session cookies for qBittorrent operations, better error logging, and additional checks for empty or invalid responses when interacting with external services.
qBittorrent integration improvements:
- Replaced usage of a shared
_httpClientwith localHttpClientinstances that use aCookieContainerto preserve session cookies, ensuring authentication works reliably with qBittorrent. [1] [2] - Improved error handling and logging for login attempts, including reading and logging the response body for failed login attempts and distinguishing between authentication-disabled and other errors.
- Added checks for empty responses when retrieving torrent info before and after adding a torrent, and when fetching the queue, with appropriate warnings if responses are empty. [1] [2] [3]
Defensive response validation for other clients:
- Added checks for empty response bodies when adding torrents to Transmission, SABnzbd, and NZBGet, logging warnings and avoiding further processing if the response is empty. [1] [[2]](diffhunk://#diff-828cad5cc8bf23dba88a7e446ca60d8d140a1a25d5d8928105ba0bb45b18f810R958...
Automated canary build