fedarovich / qbittorrent-net-client

qBittorrent client library for .Net
MIT License
32 stars 14 forks source link

Starting with qBittorrent 4.4.4, ShutdownApplicationAsync() returns “405 (Method Not Allowed)” #17

Open baccccccc opened 2 years ago

baccccccc commented 2 years ago

I'm using the library version 1.8.22216.3 which is the latest available on NuGet.

I use it in PowerShell (works great overall!), so the repro is fairly trivial.

PowerShell 5.1 using .NET Framework 4.8.1 on Windows 11 (latest version with all updates)

PS> $Client.GetQBittorrentVersionAsync()

Result                 : 4.4.5
Id                     : 69349
Exception              : 
Status                 : RanToCompletion
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             : 
IsFaulted              : False
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False

PS> $Client.ShutdownApplicationAsync()

Result                 : 
Id                     : 70903
Exception              : System.AggregateException: One or more errors occurred. ---> QBittorrent.Client.QBittorrentClientRequestException: Response status code does not indicate success: 405 (Method Not Allowed).
                            at QBittorrent.Client.Extensions.HttpClientExtensions.EnsureSuccessStatusCodeEx(HttpResponseMessage message)
                            at QBittorrent.Client.QBittorrentClient.<ShutdownApplicationAsync>d__69.MoveNext()
                            --- End of inner exception stack trace ---
                         ---> (Inner Exception #0) QBittorrent.Client.QBittorrentClientRequestException: Response status code does not indicate success: 405 (Method Not Allowed).
                            at QBittorrent.Client.Extensions.HttpClientExtensions.EnsureSuccessStatusCodeEx(HttpResponseMessage message)
                            at QBittorrent.Client.QBittorrentClient.<ShutdownApplicationAsync>d__69.MoveNext()<---

Status                 : Faulted
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             : 
IsFaulted              : True
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False

PS> $Client.ShutdownApplicationAsync( [System.Threading.CancellationToken]::new( $false ) )

Result                 : 
Id                     : 73244
Exception              : System.AggregateException: One or more errors occurred. ---> QBittorrent.Client.QBittorrentClientRequestException: Response status code does not indicate success: 405 (Method Not Allowed).
                            at QBittorrent.Client.Extensions.HttpClientExtensions.EnsureSuccessStatusCodeEx(HttpResponseMessage message)
                            at QBittorrent.Client.QBittorrentClient.<ShutdownApplicationAsync>d__69.MoveNext()
                            --- End of inner exception stack trace ---
                         ---> (Inner Exception #0) QBittorrent.Client.QBittorrentClientRequestException: Response status code does not indicate success: 405 (Method Not Allowed).
                            at QBittorrent.Client.Extensions.HttpClientExtensions.EnsureSuccessStatusCodeEx(HttpResponseMessage message)
                            at QBittorrent.Client.QBittorrentClient.<ShutdownApplicationAsync>d__69.MoveNext()<---

Status                 : Faulted
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             : 
IsFaulted              : True
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False

The same code worked as expected on 4.4.3.1 and below.