This repository has been archived by the owner on Jan 24, 2021. It is now read-only.
Replace dependency on RequestStream in Request.Body with Stream #2512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Use case:
We're uploading large blob files via a Nancy API
The default
RequestStream
implementation spools out to disk where the size of the incoming request is >85kb to avoid pressure on the Large Object HeapWhen requests are aborted, or generally when errors occur, these temp files can leak and cause %TEMPDIR% to run out of space. (I have submitted a few PRs around this in the past but it seems we can't avoid this behaviour, we can't clean up the file in the
RequestStream
destructor as in the finalizer we have lost the reference to theFile
)Since
RequestStream
is a drop-in-replacement forStream
, it seems logical to use the base class as theBody
property onRequest
, this will allow me to swap in a differentStream
implementation such as https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStreamThis also includes tracing so I can troubleshoot where Nancy may be leaking the
Request.Body
stream.I can't inherit from/override
RequestStream
since it has no paramaterless ctor, and this would be a cleaner approach anyhow.Warning: possible conflicts with #1920