Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/qbittorrent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New(webuiUrl string) (Client, error) {
IdleConnTimeout: 30 * time.Second,
DisableKeepAlives: false, // Enable connection reuse
}

var c = &client{
url: u,
client: http.Client{
Expand Down Expand Up @@ -98,6 +98,13 @@ func (c *client) login() error {
}
defer resp.Body.Close()

// avoid long waiting time if being upgraded to websocket connections (e.g. 101 responses)
// as per API documentation, qBittorrent returns only 200 on successful login
// so we safely treat any non-200 response as a failure
if resp.StatusCode != http.StatusOK {
return errors.New("failed to login into qBittorrent webui with status code: " + resp.Status)
}

// check result
body := make([]byte, 2)
_, err = resp.Body.Read(body)
Expand Down
Loading