Support binding request body as Stream/ReadOnlySequence<byte> maybe ReadOnlyMemory<byte>/ReadOnlySpan<byte> #38153
Labels
area-minimal
Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc
cost: M
Will take from 3 - 5 days to complete
Docs
This issue tracks updating documentation
feature-minimal-actions
Controller-like actions for endpoint routing
old-area-web-frameworks-do-not-use
*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Priority:1
Work that is critical for the release, but we could probably ship without
triage-focus
Add this label to flag the issue for focus at triage
Milestone
Is your feature request related to a problem? Please describe.
There's a common pattern where you have a web front end that ingests data and enqueues to into an azure queue (storage or service bus etc) that is then processed by a worker (https://docs.microsoft.com/en-us/azure/architecture/guide/architecture-styles/web-queue-worker). This pattern usually results in a taking an incoming JSON payload, creating a BinaryData from it (this means it's fully buffered) and enqueuing that payload to the queue.
Here's what this might look like in .NET 6:
This version has a few costs:
SomeDto
object.SomeDto
object into a single JSON ut8 byte[]Describe the solution you'd like
I would like it to be possible to grab the entire request body as a
ReadOnlySequence<byte>
, aStream
or a pooled backedMemory<byte>/Span<byte>
(though this requires a copy so we should consider this one carefully).It would enable this:
Additional context
HttpRequest.Body
ReadOnlySequence<byte>
would not be usable outside of the handler. Doing so would be dangerous since the underlying memory would be reused outside of this handler. This means fire and forget scenarios should copy the buffer.The text was updated successfully, but these errors were encountered: