diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-04-12 11:32:27 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-04-12 11:32:27 +1200 |
commit | 1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7 (patch) | |
tree | 6fa02d74fc2c43c2ad8c43ba5d669c54c43d2dc8 /netlib | |
parent | 2630da7263242411d413b5e4b2c520d29848c918 (diff) | |
parent | e58f76aec1db9cc784a3b73c3050d010bb084968 (diff) | |
download | mitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.tar.gz mitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.tar.bz2 mitmproxy-1a79ef8b6ce280563a9c5b3289ec2ecf4024c6b7.zip |
Merge branch 'master' of https://github.com/mitmproxy/netlib
Diffstat (limited to 'netlib')
-rw-r--r-- | netlib/certutils.py | 4 | ||||
-rw-r--r-- | netlib/http.py | 4 | ||||
-rw-r--r-- | netlib/http_auth.py | 10 | ||||
-rw-r--r-- | netlib/odict.py | 2 | ||||
-rw-r--r-- | netlib/tcp.py | 22 | ||||
-rw-r--r-- | netlib/wsgi.py | 8 |
6 files changed, 27 insertions, 23 deletions
diff --git a/netlib/certutils.py b/netlib/certutils.py index 5d8a56b8..f5375c03 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -120,7 +120,7 @@ class CertStoreEntry(object): self.chain_file = chain_file -class CertStore: +class CertStore(object): """ Implements an in-memory certificate store. """ @@ -288,7 +288,7 @@ class _GeneralNames(univ.SequenceOf): sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, 1024) -class SSLCert: +class SSLCert(object): def __init__(self, cert): """ Returns a (common name, [subject alternative names]) tuple. diff --git a/netlib/http.py b/netlib/http.py index d2fc6343..26438863 100644 --- a/netlib/http.py +++ b/netlib/http.py @@ -333,8 +333,8 @@ def read_response(rfile, request_method, body_size_limit, include_body=True): False ) else: - # if include_body==False then a None content means the body should be - # read separately + # if include_body==False then a None content means the body should be + # read separately content = None return httpversion, code, msg, headers, content diff --git a/netlib/http_auth.py b/netlib/http_auth.py index dca6e2f3..296e094c 100644 --- a/netlib/http_auth.py +++ b/netlib/http_auth.py @@ -3,7 +3,7 @@ from argparse import Action, ArgumentTypeError from . import http -class NullProxyAuth(): +class NullProxyAuth(object): """ No proxy auth at all (returns empty challange headers) """ @@ -59,12 +59,12 @@ class BasicProxyAuth(NullProxyAuth): return {self.CHALLENGE_HEADER:'Basic realm="%s"'%self.realm} -class PassMan(): +class PassMan(object): def test(self, username, password_token): return False -class PassManNonAnon: +class PassManNonAnon(PassMan): """ Ensure the user specifies a username, accept any password. """ @@ -74,7 +74,7 @@ class PassManNonAnon: return False -class PassManHtpasswd: +class PassManHtpasswd(PassMan): """ Read usernames and passwords from an htpasswd file """ @@ -89,7 +89,7 @@ class PassManHtpasswd: return bool(self.htpasswd.check_password(username, password_token)) -class PassManSingleUser: +class PassManSingleUser(PassMan): def __init__(self, username, password): self.username, self.password = username, password diff --git a/netlib/odict.py b/netlib/odict.py index f97f074b..7a2f611b 100644 --- a/netlib/odict.py +++ b/netlib/odict.py @@ -11,7 +11,7 @@ def safe_subn(pattern, repl, target, *args, **kwargs): return re.subn(str(pattern), str(repl), target, *args, **kwargs) -class ODict: +class ODict(object): """ A dictionary-like object for managing ordered (key, value) data. """ diff --git a/netlib/tcp.py b/netlib/tcp.py index b2f11851..10269aa4 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -64,7 +64,7 @@ class SSLKeyLogger(object): log_ssl_key = SSLKeyLogger.create_logfun(os.getenv("MITMPROXY_SSLKEYLOGFILE") or os.getenv("SSLKEYLOGFILE")) -class _FileLike: +class _FileLike(object): BLOCKSIZE = 1024 * 32 def __init__(self, o): self.o = o @@ -134,8 +134,8 @@ class Writer(_FileLike): r = self.o.write(v) self.add_log(v[:r]) return r - except (SSL.Error, socket.error), v: - raise NetLibDisconnect(str(v)) + except (SSL.Error, socket.error) as e: + raise NetLibDisconnect(str(e)) class Reader(_FileLike): @@ -302,7 +302,7 @@ class _Connection(object): self.connection.shutdown() except SSL.Error: pass - except KeyError as e: + except KeyError as e: # pragma: no cover # Workaround for https://github.com/pyca/pyopenssl/pull/183 if OpenSSL.__version__ != "0.14": raise e @@ -546,10 +546,10 @@ class TCPServer(object): try: r, w, e = select.select([self.socket], [], [], poll_interval) except select.error as ex: # pragma: no cover - if ex[0] == EINTR: - continue - else: - raise + if ex[0] == EINTR: + continue + else: + raise if self.socket in r: connection, client_address = self.socket.accept() t = threading.Thread( @@ -560,7 +560,11 @@ class TCPServer(object): self.address.host, self.address.port) ) t.setDaemon(1) - t.start() + try: + t.start() + except threading.ThreadError: + self.handle_error(connection, Address(client_address)) + connection.close() finally: self.__shutdown_request = False self.__is_shut_down.set() diff --git a/netlib/wsgi.py b/netlib/wsgi.py index 568b1f9c..bac27d5a 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -3,18 +3,18 @@ import cStringIO, urllib, time, traceback from . import odict, tcp -class ClientConn: +class ClientConn(object): def __init__(self, address): self.address = tcp.Address.wrap(address) -class Flow: +class Flow(object): def __init__(self, address, request): self.client_conn = ClientConn(address) self.request = request -class Request: +class Request(object): def __init__(self, scheme, method, path, headers, content): self.scheme, self.method, self.path = scheme, method, path self.headers, self.content = headers, content @@ -35,7 +35,7 @@ def date_time_string(): return s -class WSGIAdaptor: +class WSGIAdaptor(object): def __init__(self, app, domain, port, sversion): self.app, self.domain, self.port, self.sversion = app, domain, port, sversion |