Closed
Description
Hello!
As for me, documentation for a constructor of PushStreamContent which receives an asynchronous action looks a bit unclear.
It's said The stream is automatically closed when the return task is completed
but actually it isn't. Here code waits for TaskSource.Task
completition that is only caused by manual calling stream.Dispose()
: link
So this content will never be completed
new PushStreamContent(async (stream, content, transport) => {
await JsonSerializer.SerializeAsync(stream, data);
});
And we have to close the stream manually to make it work
new PushStreamContent(async (stream, content, transport) => {
await JsonSerializer.SerializeAsync(stream, data);
stream.Dispose();
});
You can compare the constructor with another one (receiving sync action). Docs there look more correct