summaryrefslogtreecommitdiff
path: root/tests/tinyproxy.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tinyproxy.py')
-rwxr-xr-xtests/tinyproxy.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
index 044eba2..88f5688 100755
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -12,7 +12,7 @@ Any help will be greatly appreciated. SUZUKI Hisao
__version__ = "0.2.1"
-import BaseHTTPServer, select, socket, SocketServer, urlparse, os
+import BaseHTTPServer, select, socket, SocketServer, urlparse
class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
__base = BaseHTTPServer.BaseHTTPRequestHandler
@@ -23,8 +23,7 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
def handle(self):
(ip, port) = self.client_address
- allowed = getattr(self, 'allowed_clients', None)
- if allowed is not None and ip not in allowed:
+ if hasattr(self, 'allowed_clients') and ip not in self.allowed_clients:
self.raw_requestline = self.rfile.readline()
if self.parse_request():
self.send_error(403)
@@ -47,7 +46,7 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
try: soc.connect(host_port)
except socket.error, arg:
try: msg = arg[1]
- except (IndexError, TypeError): msg = arg
+ except: msg = arg
self.send_error(404, msg)
return 0
return 1
@@ -122,12 +121,7 @@ class ProxyHandler (BaseHTTPServer.BaseHTTPRequestHandler):
do_DELETE = do_GET
class ThreadingHTTPServer (SocketServer.ThreadingMixIn,
- BaseHTTPServer.HTTPServer):
- def __init__(self, *args, **kwargs):
- BaseHTTPServer.HTTPServer.__init__(self, *args, **kwargs)
- a = open("proxy.pid", "w")
- a.write(str(os.getpid()) + "\n")
- a.close()
+ BaseHTTPServer.HTTPServer): pass
if __name__ == '__main__':
from sys import argv