Oliver
Oliver

Reputation: 11617

Get raw data from Http Request?

I want to save the raw, full data of an HttpRequest. 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 raw form, http requests are transfered as header fields followed by the body, so it should be possible to get the raw text representation of the whole request, but I can't work out how.

Upvotes: 4

Views: 5623

Answers (1)

Jon
Jon

Reputation: 437854

You can pull them out of the Headers property (Apologies for this being kind of an obvious suggestion). It may not be as convenient as "give me everything in raw format", but it's code you will only have to write once.

Upvotes: 4

Related Questions