简体   繁体   中英

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

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 some 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM