Nancy icon indicating copy to clipboard operation
Nancy copied to clipboard

Not possible for Response implementations to write async content.

Open jlennox opened this issue 9 years ago • 5 comments

Proposed solution: In addition to Action<Stream> Contents there could be Action<Task<Stream>> AsyncContents which takes presidence when non-null.

An example of code that suffers from the non-presence of this feature: https://github.com/NancyFx/Nancy/blob/master/src/Nancy/Responses/StreamResponse.cs

StreamResponse will block the thread during read and write IO.

jlennox avatar Oct 03 '15 00:10 jlennox

:+1: This will be done as part of the 2.0 overhaul.

We're planning on dropping 4.0 support and go full-blown async/await all over the place. The Contents property will most likely be a Func<Stream, Task> :smile:

I'll leave this open for tracking :watch:

khellang avatar Oct 03 '15 00:10 khellang

Waiting for #2105 to be merged first.

damianh avatar Dec 07 '15 22:12 damianh

Any news on this?. Would be nice if Process on IResponseProcessor could return a Task<Response> instead of Response. Or that Response.Contents Can take Func<Stream,Task> instead of Action<Stream>

btrepp avatar May 04 '16 03:05 btrepp

Hi, was this implemented with v2.0.0 ? I can't seem to find the method.

corentinaltepe avatar Aug 22 '19 11:08 corentinaltepe

Any update?

tasoss avatar Sep 27 '19 22:09 tasoss