Get raw data from an Http request?

I want to save raw full HttpRequest data. At the moment I have this:

 Request.ContentEncoding.GetString(Request.BinaryRead(int.MaxValue)); 

But this only gets the body of the HttpRequest. I also want to get the headers. In the original form, HTTP requests are transmitted as header fields followed by the body, so it should be possible to get an unprocessed textual representation of the entire request, but I cannot figure out how to do this.

+4
source share
1 answer

You can pull them out of the Headers property (apologies for the obvious suggestion). It may not be as convenient as "give me everything in raw format," but it is code that you only need to write once.

+4
source

Source: https://habr.com/ru/post/1384706/


All Articles