OwinResponse.Body is normally set to a type of OutputStream which is not readable

Topics: ASP.NET Web API, General
Aug 11, 2013 at 11:00 PM
Why OwinResponse.Body is set to a type of OutputStream (not-readable)? So how does the middleware model supposed to work?

It can be very common for middleware model of OWIN middlewares to be able to manipulate the body so a stream which is only writeable defeats the model.
Aug 14, 2013 at 12:48 AM
That would require the response to always be buffered.

Middleware can choose to manipulate the response by either:
  • Replace the stream with a buffer, do the manipulation, and then copy to the original stream.
  • Replace the stream with a wrapper stream that does the manipulation inline.
Aug 14, 2013 at 10:25 AM
Edited Aug 16, 2013 at 8:45 AM
Thanks. Makes sense.


Well, sorry doesn't. Please see my reply below.
Aug 15, 2013 at 8:39 AM
Sorry, now that I thought about implementing it, how would I replace a write-only stream with a wrapper? How would it work, I cannot read it anyway.