]> khamidou — GitHub mirrors - tunnel.git/commitdiff
the command-line proxy now works
authorkhamidou <khamidou@gmail.com>
Tue, 8 Dec 2009 16:42:45 +0000 (17:42 +0100)
committerkhamidou <khamidou@gmail.com>
Tue, 8 Dec 2009 16:42:45 +0000 (17:42 +0100)
tunnel.py

index b7b73ff7d2e9a7fb43d17e3e0c1cc5ffd1e4625a..4f562e029907f8fb0765a00958823a891a6aa30f 100755 (executable)
--- a/tunnel.py
+++ b/tunnel.py
@@ -26,8 +26,15 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
             headers = {"Proxy-Connection" : "", }
             req = urllib2.Request(self.path, headers=headers) 
             
-            data = urllib2.urlopen(req)
-            s.wfile.write(data.read())
+            try:
+               data = urllib2.urlopen(req)
+                self.send_response(200)
+                self.end_headers()
+                self.wfile.write(data.read())
+
+            except IOError:
+                self.send_response(500)
+                self.end_headers()
             
     do_HEAD = do_GET
     do_POST = do_GET