Personal tools
You are here: Home kaeru's blog Archive 2007 October 14 Twisted - Proxy in 7 lines
Document Actions

Twisted - Proxy in 7 lines

by kaeru last modified 2007-10-15 01:27
Filed Under:

You can find the example here, where you will also find some information and links to Twisted.

I needed a simple non-caching http proxy to be available on my server via VPN. Surfing at home therefore will not be affected by Streamyx transparent proxy. Don't you just hate being limited to <8KB/s transfer on your 1Mb line?

Before I picked up Twisted, I actually picked up a  Java Servlets book. Experience gained from earlier projects, taught me that there is a need for simple, lightweight and fast network application servers to do jobs like this, especially if you need to do atomic operations that require input from different sources. Actually Servlets do the job well and the javax.* libraries are also not so verbose. If it wasn't for a Python preference, I'd probably use Java servlets instead for this role. You may want to investigate similar libraries for your favorite language too. It's a good tool to add to your development toolkit.

Update:
Additional testing showed that for streaming http audio requests, it does not close the connection when the client stops. Even if the request is via a squid client proxy. A Proxy class instance continues to download . This is a good learning experience, as I'll need to extend the simple example to show HTTP headers to see what's the  difference with other requests which are handled correctly, and then deal with the streaming audio proxy instances.

Great!

Posted by mysurface at 2007-10-15 01:25
Checked the codes, that is great! Neat and easy to understand.


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: