twitchax / AspNetCore.Proxy

ASP.NET Core Proxies made easy.
MIT License
525 stars 83 forks source link

Is it possible to capture and log the amount of data transfer through the proxy? #50

Closed bnssoftware closed 4 years ago

bnssoftware commented 4 years ago

I'm setting up a proxy to enable routing client requests to particular bucket/path in AWS S3. Is it possible to log the amount of data transfer happening through the proxy? If so, are there any examples of how this might be done?

twitchax commented 4 years ago

Hi @bnssoftware, you can use WithAfterReceive on the HttpProxyOptions to inspect the response as it comes through. I'm not sure how you would want to design it, since reading from the response stream requires that you repopulate it (since the stream is gone once you read it). However, that is the best place to inspect the response or size of the response.

An example of WithAfterReceive is in the README.