fedarovich / qbittorrent-cli

Command line interface for QBittorrent
MIT License
303 stars 16 forks source link

unexplained 404 error #30

Closed devster31 closed 8 months ago

devster31 commented 4 years ago

Hello I'm running the following:

When trying to use any qbittorrent-cli commands this is what happens:

qbt server info --url https://<fqdn>/qbt/ --username <username> --password <password> --print-stacktrace
QBittorrent.Client.QBittorrentClientRequestException: Response status code does not indicate success: 404 (Not Found).
   at QBittorrent.Client.Extensions.HttpClientExtensions.EnsureSuccessStatusCodeEx(HttpResponseMessage message)
   at QBittorrent.Client.QBittorrentClient.PostAsync(Func`2 builder, CancellationToken token, ApiLevel minApiLevel, ApiVersion minApiVersion)
   at QBittorrent.CommandLineInterface.Commands.ClientCommandBase.AuthenticateAsync(QBittorrentClient client)
   at QBittorrent.CommandLineInterface.Commands.AuthenticatedCommandBase.OnExecuteAsync(CommandLineApplication app, IConsole console)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context)
   at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass142_0.<OnExecute>b__0()
   at QBittorrent.CommandLineInterface.Program.Main(String[] args)

However using another HTTP client works as expected:

http --follow --session <mysession> http://<fqdn>/qbt/api/v2/app/buildInfo
HTTP/1.1 200 OK
Content-Length: 101
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none'; form-action 'self'; frame-ancestors 'self';
Content-Type: application/json
Date: Sat, 08 Feb 2020 18:31:16 GMT
Referrer-Policy: same-origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{
    "bitness": 64,
    "boost": "1.65.1",
    "libtorrent": "1.2.3.0",
    "openssl": "1.1.1",
    "qt": "5.9.5",
    "zlib": "1.2.11"
}

http stands for httpie and I had already logged in with:

http -v --follow --session <mysession> http://<fqdn>/qbt/api/v2/auth/login  username==<username> password==<password>
HTTP/1.1 200 OK
Content-Length: 3
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none'; form-action 'self'; frame-ancestors 'self';
Content-Type: text/plain
Date: Sat, 08 Feb 2020 18:24:06 GMT
Referrer-Policy: same-origin
Set-Cookie: SID=4L8f+2KKS/j3R6P9KJF2q9SECHf5MWDh; HttpOnly; path=/; SameSite=Strict
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

Ok.

The entire connection flow includes a redirect as I'm hosting qBittorrent at /qbt:

http --follow --session brew http://<fqdn>/qbt/api/v2/app/buildInfo
GET /qbt/api/v2/app/buildInfo HTTP/1.1
User-Agent: HTTPie/2.0.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Cookie: SID=4L8f+2KKS/j3R6P9KJF2q9SECHf5MWDh
Authorization: Basic ZGV2c3RlcjpEZXZhc3RhdG9yMzE=
Host: <fqdn>

HTTP/1.1 302 Found
Location: https://<fqdn>/qbt/api/v2/app/buildInfo
Date: Sat, 08 Feb 2020 19:01:09 GMT
Content-Length: 5
Content-Type: text/plain; charset=utf-8

Found

GET /qbt/api/v2/app/buildInfo HTTP/1.1
User-Agent: HTTPie/2.0.0
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Authorization: Basic ZGV2c3RlcjpEZXZhc3RhdG9yMzE=
Cookie: SID=4L8f+2KKS/j3R6P9KJF2q9SECHf5MWDh
Host: <fqdn>

HTTP/1.1 200 OK
Content-Length: 101
Content-Security-Policy: default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self' 'unsafe-inline'; object-src 'none'; form-action 'self'; frame-ancestors 'self';
Content-Type: application/json
Date: Sat, 08 Feb 2020 19:01:09 GMT
Referrer-Policy: same-origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block

{
    "bitness": 64,
    "boost": "1.65.1",
    "libtorrent": "1.2.3.0",
    "openssl": "1.1.1",
    "qt": "5.9.5",
    "zlib": "1.2.11"
}
mateusbirnbaum commented 4 years ago

I'm having the same issue! Has any solution/workaround been found? Thanks

zhongfu commented 1 year ago

if anyone's still wondering, it seems like qbittorrent-cli ignores the path part of the provided URL (and thus makes requests to https://blah/api/v2/... instead of e.g. https://blah/qbt/api/v2/...)

fedarovich commented 8 months ago

Fixed in version 1.8 (currently nightly builds, will be release in a few days)