mirror of
https://github.com/zhigang1992/mitmproxy.git
synced 2026-04-23 11:56:52 +08:00
fix code smell
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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):
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user