Describe the bug
Like the title says, it is not possible to call any overload of FetchApodAsync twice without running into weird errors or exceptions, which is likely due to http objects not being disposed of correctly.
To Reproduce
Steps to reproduce the behavior:
Pick one of the overloads of ApodClient.FetchApodAsync()
Call it twice
See errors (different errors depending on which overload)
Expected behavior
No errors.
Environment (please complete the following information):
OS: Windows 8
Time zone: UTC+1
Additional context
Calling FetchApodAsync(DateTime date) or FetchApodAsync(DateTime startDate, DateTime endDate) more than once:
{"code":400,"msg":"unconverted data remains: https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY","service_version":"v1"}
Calling FetchApodAsync(int amount) more than once (where the number before the URL is the first number you passed into amount, in this case 3:
{"code":400,"msg":"invalid literal for int() with base 10: '3https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY'","service_version":"v1"}
Calling FetchApodAsync() more than once:
Unhandled exception. System.ObjectDisposedException: Cannot access a closed Stream.
at System.IO.MemoryStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.MemoryStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Text.Json.JsonSerializer.ReadAsync[TValue](Stream utf8Json, Type returnType, JsonSerializerOptions options, CancellationToken cancellationToken)
at Apod.Logic.Net.HttpResponseParser.ParseSingleApodAsync(HttpResponseMessage httpResponse) in C:\Projects\APOD.Net\src\Apod\Logic\Net\HttpResponseParser.cs:line 34
at Apod.ApodClient.FetchApodAsync() in C:\Projects\APOD.Net\src\Apod\ApodClient.cs:line 47
at ApodExample.Program.Main() in C:\Projects\APOD.Net\src\ExampleUsage\Program.cs:line 21
at ApodExample.Program.<Main>()
Describe the bug Like the title says, it is not possible to call any overload of FetchApodAsync twice without running into weird errors or exceptions, which is likely due to http objects not being disposed of correctly.
To Reproduce Steps to reproduce the behavior:
ApodClient.FetchApodAsync()
Expected behavior No errors.
Environment (please complete the following information):
Additional context Calling
FetchApodAsync(DateTime date)
orFetchApodAsync(DateTime startDate, DateTime endDate)
more than once:Calling
FetchApodAsync(int amount)
more than once (where the number before the URL is the first number you passed intoamount
, in this case3
:Calling
FetchApodAsync()
more than once: