From 4f37f405a058fe7adc74bdfab899ad374a8ecb55 Mon Sep 17 00:00:00 2001 From: Aractor Date: Thu, 23 Jul 2026 21:02:01 -0700 Subject: [PATCH] Handle 204 No Content response for qBittorrent login Update login response handling for qBittorrent 5.2.0 to accept 204 No Content as a successful login. --- qbit.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qbit.go b/qbit.go index f0f9100..fa3ad1e 100644 --- a/qbit.go +++ b/qbit.go @@ -174,6 +174,13 @@ func (q *Qbit) login(ctx context.Context) error { body, _ := io.ReadAll(resp.Body) + // qBittorrent 5.2.0+ returns 204 No Content (with an empty body) on a + // successful login, instead of the previous 200 OK with "Ok." in the + // body. Accept 204 as success without requiring the old body match. + if resp.StatusCode == http.StatusNoContent { + return nil + } + if resp.StatusCode != http.StatusOK || !strings.Contains(string(body), "Ok.") { return fmt.Errorf("%w: %s: %s: %s", ErrLoginFailed, resp.Status, req.URL, string(body)) }