I am wondering if there is a straightforward way to use .NET's built in HTTP support to parse arbitrary bytes into nice HTTP requests and responses. For example, I would like to be able to pass in a byte array containing "HTTP/200 OK\r\nContent-Type:...." etc and get out 开发者_如何学Csome structure representing the status code, and decoded content.
I'm afraid there is not built-in support for this that you can access. This logic is embedded in internals of the HttpWebRequest
-related classes of the .NET Framework.
I think the closest you can get is hosting your own web server through the System.Web.Hosting APIs, but this sounds too heavyweight for what you are describing.
精彩评论