I'm trying to write a .NET Core API Controller action that would basically act like a HTTP proxy:
- Data comes in
POST
ed viaRequest.Body
stream - Then
POST
ed to another backend service which processes the input data stream live and starts sending result back while still reading and processing input - Resulting
POST
response is read and streamed back to the caller of this 'proxy'
I tried a couple of things, playing with both HttpClient
and old HttpWebRequest
but still can't make this work properly, the process deadlocks somewhere.
I would also like to better control if possible the HTTP request output buffers as I observed that data starts to pile up in-memory if backend service can't accept it fast enough (stream.Write()
calls don't block immediately and process memory spikes).
Any ideas or examples?