Last post Apr 09, 2014 01:13 PM by Darrel Miller
Apr 09, 2014 03:53 AM|asondf|LINK
why request body is a non-rewindable stream i.e we cant read the content more than once
Apr 09, 2014 04:46 AM|AidyF|LINK
Because that's what a stream is, it is the sending of data and how you process the data depends on your needs, and the request\response streams represent the underlying network streams. If you only need the data once you process it as it comes. If you
need to process it as a whole you have to collect the data as it comes and hold it somewhere until all data has arrived. If you want to re-read it then you have to hold it in a structure that isn't a stream, and can be accessed how you want. Think of it like
a stream of water from your tap. It comes in a stream and you can't re-wind it, if you want to keep the water you need to hold it in a bucket as the format it is delivered (the stream) isn't suitable for everything you might want to do with the water.
Apr 09, 2014 05:06 AM|PatriceSc|LINK
An http request *is* a non-rewindable stream (as all incoming network data). Exposing this as a rewindable stream would put too much constraints on the implementation (you have to preserve this behavior forever, you have to store those data even if most
users don't need a rewindable stream etc...) for likely little benefits...
So it has been considered best to expose this as it really is and to let users that really need something more to deal themselves with this.
Apr 09, 2014 01:13 PM|Darrel Miller|LINK
Calling request.Content.LoadIntoBufferAsync() will move the bytes from the network stream into a memory stream and allow you to reposition the stream and read it multiple times.