mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Code cleanliness - appease pychecker.
This commit is contained in:
parent
730c78ac53
commit
b51aac8a86
@ -864,8 +864,6 @@ class Options(object):
|
||||
"limit",
|
||||
"no_server",
|
||||
"refresh_server_playback",
|
||||
"request_script",
|
||||
"response_script",
|
||||
"rfile",
|
||||
"script",
|
||||
"rheaders",
|
||||
@ -952,11 +950,6 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
self.conn_list_view = None
|
||||
self.set_palette()
|
||||
|
||||
if options.response_script:
|
||||
self.set_response_script(options.response_script)
|
||||
if options.request_script:
|
||||
self.set_request_script(options.request_script)
|
||||
|
||||
r = self.set_limit(options.limit)
|
||||
if r:
|
||||
print >> sys.stderr, "Limit error:", r
|
||||
@ -1085,15 +1078,14 @@ class ConsoleMaster(flow.FlowMaster):
|
||||
return txt
|
||||
|
||||
def _view_conn_urlencoded(self, lines):
|
||||
kv = format_keyvals(
|
||||
[(k+":", v) for (k, v) in lines],
|
||||
key = "header",
|
||||
val = "text"
|
||||
)
|
||||
return [
|
||||
urwid.Text(("highlight", "URLencoded data:\n")),
|
||||
urwid.Text(
|
||||
format_keyvals(
|
||||
[(k+":", v) for (k, v) in lines],
|
||||
key = "header",
|
||||
val = "text"
|
||||
)
|
||||
)
|
||||
urwid.Text(kv)
|
||||
]
|
||||
|
||||
def _find_pretty_view(self, content, hdrItems):
|
||||
|
@ -2,7 +2,7 @@
|
||||
This module provides more sophisticated flow tracking. These match requests
|
||||
with their responses, and provide filtering and interception facilities.
|
||||
"""
|
||||
import subprocess, sys, json, hashlib, Cookie, cookielib, base64, copy, re
|
||||
import json, hashlib, Cookie, cookielib, base64, copy, re
|
||||
import time
|
||||
import netstring, filt, script, utils, encoding, proxy
|
||||
from email.utils import parsedate_tz, formatdate, mktime_tz
|
||||
|
@ -5,10 +5,10 @@
|
||||
|
||||
Development started from Neil Schemenauer's munchy.py
|
||||
"""
|
||||
import sys, os, string, socket, select, time, Cookie
|
||||
import sys, os, string, socket, select, time
|
||||
import shutil, tempfile, threading
|
||||
import optparse, SocketServer, ssl
|
||||
import utils, controller, flow
|
||||
import utils, flow
|
||||
|
||||
NAME = "mitmproxy"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import imp, os, traceback, flow
|
||||
import os, traceback
|
||||
|
||||
class ScriptError(Exception):
|
||||
pass
|
||||
@ -14,7 +14,6 @@ class Script:
|
||||
"""
|
||||
def __init__(self, path, ctx):
|
||||
self.path, self.ctx = path, ctx
|
||||
self.mod = None
|
||||
self.ns = None
|
||||
|
||||
def load(self):
|
||||
@ -31,7 +30,7 @@ class Script:
|
||||
raise ScriptError("Not a file: %s"%self.path)
|
||||
ns = {}
|
||||
try:
|
||||
self.mod = execfile(path, ns, ns)
|
||||
execfile(path, ns, ns)
|
||||
except Exception, v:
|
||||
raise ScriptError(traceback.format_exc(v))
|
||||
self.ns = ns
|
||||
|
@ -13,7 +13,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import re, os, subprocess, datetime, urlparse, string
|
||||
import time, functools, copy, cgi, textwrap
|
||||
import time, functools, cgi, textwrap
|
||||
import json
|
||||
|
||||
CERT_SLEEP_TIME = 1
|
||||
|
@ -1,4 +1,4 @@
|
||||
import socket, os, cStringIO, tempfile
|
||||
import socket
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
import handler
|
||||
|
@ -1,4 +1,4 @@
|
||||
import socket, os, cStringIO, tempfile
|
||||
import socket
|
||||
from SocketServer import BaseServer
|
||||
from BaseHTTPServer import HTTPServer
|
||||
import ssl
|
||||
|
@ -70,7 +70,6 @@ class uDumpMaster(libpry.AutoTree):
|
||||
m = dump.DumpMaster(None, o, None, outfile=cs)
|
||||
|
||||
def test_read(self):
|
||||
cs = StringIO()
|
||||
t = self.tmpdir()
|
||||
p = os.path.join(t, "read")
|
||||
self._flowfile(p)
|
||||
@ -130,10 +129,10 @@ class uDumpMaster(libpry.AutoTree):
|
||||
)
|
||||
|
||||
def test_stickycookie(self):
|
||||
ret = self._dummy_cycle(1, None, "", stickycookie = ".*")
|
||||
self._dummy_cycle(1, None, "", stickycookie = ".*")
|
||||
|
||||
def test_stickyauth(self):
|
||||
ret = self._dummy_cycle(1, None, "", stickyauth = ".*")
|
||||
self._dummy_cycle(1, None, "", stickyauth = ".*")
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@ from libmproxy import encoding
|
||||
import libpry
|
||||
|
||||
import cStringIO
|
||||
import gzip, zlib
|
||||
|
||||
class uidentity(libpry.AutoTree):
|
||||
def test_simple(self):
|
||||
|
@ -241,7 +241,6 @@ class uFlow(libpry.AutoTree):
|
||||
|
||||
class uState(libpry.AutoTree):
|
||||
def test_backup(self):
|
||||
bc = flow.ClientConnect(("address", 22))
|
||||
c = flow.State()
|
||||
req = tutils.treq()
|
||||
f = c.add_request(req)
|
||||
@ -285,10 +284,8 @@ class uState(libpry.AutoTree):
|
||||
assert c.add_response(resp)
|
||||
assert c.active_flow_count() == 0
|
||||
|
||||
dc = flow.ClientDisconnect(bc)
|
||||
|
||||
def test_err(self):
|
||||
bc = flow.ClientConnect(("address", 22))
|
||||
c = flow.State()
|
||||
req = tutils.treq()
|
||||
f = c.add_request(req)
|
||||
@ -305,7 +302,7 @@ class uState(libpry.AutoTree):
|
||||
req = tutils.treq()
|
||||
assert len(c.view) == 0
|
||||
|
||||
f = c.add_request(req)
|
||||
c.add_request(req)
|
||||
assert len(c.view) == 1
|
||||
|
||||
c.set_limit("~s")
|
||||
@ -342,7 +339,7 @@ class uState(libpry.AutoTree):
|
||||
|
||||
def _add_response(self, state):
|
||||
req = tutils.treq()
|
||||
f = state.add_request(req)
|
||||
state.add_request(req)
|
||||
resp = tutils.tresp(req)
|
||||
state.add_response(resp)
|
||||
|
||||
@ -539,7 +536,7 @@ class uFlowMaster(libpry.AutoTree):
|
||||
tf = tutils.tflow_full()
|
||||
tf.response.headers["set-cookie"] = ["foo=bar"]
|
||||
fm.handle_request(tf.request)
|
||||
f = fm.handle_response(tf.response)
|
||||
fm.handle_response(tf.response)
|
||||
assert fm.stickycookie_state.jar
|
||||
assert not "cookie" in tf.request.headers
|
||||
fm.handle_request(tf.request)
|
||||
@ -690,7 +687,6 @@ class uResponse(libpry.AutoTree):
|
||||
h = flow.Headers()
|
||||
h["test"] = ["test"]
|
||||
c = flow.ClientConnect(("addr", 2222))
|
||||
r = flow.Request(c, "host", 22, "https", "GET", "/", h, "content")
|
||||
req = flow.Request(c, "host", 22, "https", "GET", "/", h, "content")
|
||||
resp = flow.Response(req, 200, "msg", h.copy(), "content")
|
||||
|
||||
|
@ -9,10 +9,10 @@ class uNetstring(libpry.AutoTree):
|
||||
self.encoded_data = "9:Netstring,6:module,2:by,4:Will,7:McGugan,"
|
||||
|
||||
def test_header(self):
|
||||
tests = [ ("netstring", "9:"),
|
||||
t = [ ("netstring", "9:"),
|
||||
("Will McGugan", "12:"),
|
||||
("", "0:") ]
|
||||
for test, result in tests:
|
||||
for test, result in t:
|
||||
assert netstring.header(test) == result
|
||||
|
||||
def test_file_encoder(self):
|
||||
|
@ -1,7 +1,6 @@
|
||||
import cStringIO, time, re
|
||||
import cStringIO, time
|
||||
import libpry
|
||||
from libmproxy import proxy, controller, utils, dump
|
||||
import tutils
|
||||
|
||||
|
||||
class u_read_chunked(libpry.AutoTree):
|
||||
|
@ -40,7 +40,7 @@ class upretty_size(libpry.AutoTree):
|
||||
def test_simple(self):
|
||||
assert utils.pretty_size(100) == "100B"
|
||||
assert utils.pretty_size(1024) == "1kB"
|
||||
assert utils.pretty_size(1024 + (1024/2)) == "1.5kB"
|
||||
assert utils.pretty_size(1024 + (1024/2.0)) == "1.5kB"
|
||||
assert utils.pretty_size(1024*1024) == "1M"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user