Replace dependency on RequestStream in Request.Body with Stream#2512
Replace dependency on RequestStream in Request.Body with Stream#2512horsdal merged 1 commit intoNancyFx:masterfrom
Conversation
Allows swapping out switchover stream behaviour
|
With this change, I can swap out Nancy/src/Nancy/Owin/NancyMiddleware.cs Line 84 in a9989a6 |
|
I've reviewed #1920 and I'm fairly sure this change will have no impact on that PR. |
|
This looks fine to me, we will still use RequestStream but others can use another inherited Stream class and write their own Middleware extension to use that |
|
Assuming this is ok to merge, any chance of getting it backported to 1.x? |
|
Pinging @thecodejunkie On Wednesday, 3 August 2016, Dan Barua notifications@github.com wrote:
|
|
Agree that this is good to go. Merging |
Allows swapping out switchover stream behaviour Backport of NancyFx#2512
Prerequisites
Description
Use case:
We're uploading large blob files via a Nancy API
The default
RequestStreamimplementation 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
RequestStreamdestructor as in the finalizer we have lost the reference to theFile)Since
RequestStreamis a drop-in-replacement forStream, it seems logical to use the base class as theBodyproperty onRequest, this will allow me to swap in a differentStreamimplementation such as https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStreamThis also includes tracing so I can troubleshoot where Nancy may be leaking the
Request.Bodystream.I can't inherit from/override
RequestStreamsince it has no paramaterless ctor, and this would be a cleaner approach anyhow.Warning: possible conflicts with #1920