Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

How to handle HTTP Connect in .NET?

I would like to handle HTTP on very low level - at the moment I'm stuck with HTTP CONNECT verb. It looks like HttpListener doesn't have access to these request because they are handled somewhere inside HTTP API or HTTP.SYS. I'm able to handle such requests with native TcpListener but in such case I would lose all HTTP functionality = I would implement HTTP from scratch.

I also checked FiddlerCore but it also handles these requests on some Win API layer. Is there any pure .NET HTTP stack?

Edit: I'm working on HTTP proxy with some additional request analysis and statistics so I don't want to lose HTTP parsing and in the same time I want to know about SSL connections.

Upvotes: 0

Views: 1865

Answers (3)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364409

Ok. Again the problem is not in API but in developer :)

I have some test suite to test my implementation but the test suite was connecting directly (not as to a proxy) - that was the first problem. The second problem was that this test suite should use TcpClient instead of HttpWebRequest if I want to test Connect verb separately because HttpWebRequest uses it only internally when using proxy for HTTPS.

Upvotes: 0

Well, if you are building your custom HTTP/HTTPS server or proxy and you don't mind third-party components, then our SecureBlackbox includes HTTP/HTTPS server components which let you do almost anything with any verb. Pure .NET, use any socket classes.

Upvotes: 1

Default Writer
Default Writer

Reputation: 2566

Use Tcp* ans Socket*, not Http* related classes to use really low level in .NET.

TCP is at the bottom of HTTP protocol stack.

Use TCP sockets if you want it to, just use "winsock2.dll" interop calls form c#, and all related stuff like structure definitions etc, or use native C++

Upvotes: 1

Related Questions