The Wayback Machine - https://web.archive.org/web/20220123005126/https://github.com/dotnet/aspnetcore/issues/39711
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support returning Stream and PipeReader directly from route handler methods #39711

Open
1 task done
davidfowl opened this issue Jan 23, 2022 · 0 comments
Open
1 task done

Comments

@davidfowl
Copy link
Member

@davidfowl davidfowl commented Jan 23, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Today we support several built in types as result types (along with async versions), string, IResult, any other object (JSON). The idea is to extend support for Stream and PipeReader (along with the async versions). This provides symmetry with automatic binding of Stream and PipeReader in the input and as the built in version of #39383.

Describe the solution you'd like

This is an extension of #39383 to natively understand Stream, Task<Stream>, ValueTask<Stream>, PipeReader, Task<PipeReader>, and ValueTask<PipeReader> as a return type from handler methods. The default behavior would be:

  • Set the content type to "application/octet-stream" (if it's not already set)
  • We always copy the entire stream to the response body
  • Does not support range requests
  • Does not support download file names

Additional context

app.MapGet("/blob/download1", () =>
{
    return File.OpenRead("../something.txt");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant