开发者

Is there a way to use .NET's built-in HTTP classes to parse "raw" TCP streams as HTTP from memory?

开发者 https://www.devze.com 2022-12-10 23:48 出处:网络
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 b

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消