KestrelHttpServer icon indicating copy to clipboard operation
KestrelHttpServer copied to clipboard

Question: Reset/forward body stream

Open Mattacks opened this issue 9 years ago • 5 comments

In a scenario where I have a server reading data from the POST body, and then upon some algorithm forwarding that to a second HTTP POST, I would like to be able to forward the whole buffer in the body without reading it first.

IE to read some bytes from the stream, then send the whole stream to another server.

Is this possible? I do not see how today because I cannot seek back to the beginning. Possible to add this? (Seeking or forwarding)

cheers

Matt

Mattacks avatar Aug 09 '17 13:08 Mattacks

Seeking isn't possible, you'd need to add your own buffering layer.

Tratcher avatar Aug 09 '17 14:08 Tratcher

I only want to seek back to zero. The whole point is to not add the overhead of a buffering layer - I just want to pipe it straight through after having peeked at a few bytes

Mattacks avatar Aug 09 '17 19:08 Mattacks

https://github.com/Drawaes/CondenserDotNet/blob/master/src/CondenserDotNet.Middleware/ProtocolSwitcher/BackToBackStream.cs

Something like but buffering more than 1 byte?

Drawaes avatar Aug 09 '17 19:08 Drawaes

By definition you will have to buffer the bytes you have read in any solution. But after that just pass the stream data through

Drawaes avatar Aug 09 '17 19:08 Drawaes

The BackToBack stream is perfect inspiration, thanks

Mattacks avatar Aug 10 '17 09:08 Mattacks