views:

2251

answers:

2

My company is experimenting with writing a proxy server using the .NET Fx 3.5 and C#. From our research I have read that HttpListener is not a good candidate for a proxy server though I am unsure as to why.

We are currently working with the Mentalis proxy example source code though that will involve, among other things, implementing our own logging and performance counters. Using HttpListener will wrap Http.sys which will give us some of the performance statistics we require out of the box.

So why is HttpListener a bad candidate for HTTP proxy work?

(And yes we are considering Squid 3.1 by writing or configuring an ICAP server as well.)

+2  A: 

HttpListener is in .NET to provide a major building block for a simple HTTP server. Where simple includes not supporting high operation rates.

Typically HTTP proxies need to be very low overhead to support many concurrent connections as well as providing the proxy's function (which depends on the type of proxy).

Proxies are detailed in RFC 2616 §8.1.3) and that immediately provides one item that (if I understand HttpListener correctly) is not possible:

The proxy server MUST signal persistent connections separately with its clients and the origin servers (or other proxy servers) that it connects to. Each persistent connection applies to only one transport link.

Richard
Doesn't IIS use http.sys? I'm not following what about it makes it bad for use as a proxy server
Sam Saffron
Http.sys is for writing HTTP servers, an HTTP proxy is not just a HTTP server that calls another one. The note about HttpListener being for "simple" cases is from MSDN (IIRC).
Richard
A: 

You might also consider that the windows port of nginx was released a few days ago. Many sites that have squid and varnish experience are very pleased after converting to nginx. Then there is always whatever MS is calling ISA server these days.

Gone off to look at the Mentalis code now :D