File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ func New(webuiUrl string) (Client, error) {
4343 IdleConnTimeout : 30 * time .Second ,
4444 DisableKeepAlives : false , // Enable connection reuse
4545 }
46-
46+
4747 var c = & client {
4848 url : u ,
4949 client : http.Client {
@@ -98,6 +98,13 @@ func (c *client) login() error {
9898 }
9999 defer resp .Body .Close ()
100100
101+ // avoid long waiting time if being upgraded to websocket connections (e.g. 101 responses)
102+ // as per API documentation, qBittorrent returns only 200 on successful login
103+ // so we safely treat any non-200 response as a failure
104+ if resp .StatusCode != http .StatusOK {
105+ return errors .New ("failed to login into qBittorrent webui with status code: " + resp .Status )
106+ }
107+
101108 // check result
102109 body := make ([]byte , 2 )
103110 _ , err = resp .Body .Read (body )
You can’t perform that action at this time.
0 commit comments