Skip to content

PushStreamContent has unclear documentation #310

Closed
@lichutin-st

Description

@lichutin-st

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions