mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
Remove last vestiges of noapi and noweb from pathod
Also hide HTTP2 freeze bug by making explain configurable in the tests
This commit is contained in:
parent
48da24ae7e
commit
375d7c9741
@ -304,9 +304,7 @@ class Pathod(tcp.TCPServer):
|
|||||||
staticdir=None,
|
staticdir=None,
|
||||||
anchors=(),
|
anchors=(),
|
||||||
sizelimit=None,
|
sizelimit=None,
|
||||||
noweb=False,
|
|
||||||
nocraft=False,
|
nocraft=False,
|
||||||
noapi=False,
|
|
||||||
nohang=False,
|
nohang=False,
|
||||||
timeout=None,
|
timeout=None,
|
||||||
logreq=False,
|
logreq=False,
|
||||||
@ -328,7 +326,6 @@ class Pathod(tcp.TCPServer):
|
|||||||
None.
|
None.
|
||||||
sizelimit: Limit size of served data.
|
sizelimit: Limit size of served data.
|
||||||
nocraft: Disable response crafting.
|
nocraft: Disable response crafting.
|
||||||
noapi: Disable the API.
|
|
||||||
nohang: Disable pauses.
|
nohang: Disable pauses.
|
||||||
"""
|
"""
|
||||||
tcp.TCPServer.__init__(self, addr)
|
tcp.TCPServer.__init__(self, addr)
|
||||||
@ -337,8 +334,8 @@ class Pathod(tcp.TCPServer):
|
|||||||
self.staticdir = staticdir
|
self.staticdir = staticdir
|
||||||
self.craftanchor = craftanchor
|
self.craftanchor = craftanchor
|
||||||
self.sizelimit = sizelimit
|
self.sizelimit = sizelimit
|
||||||
self.noweb, self.nocraft = noweb, nocraft
|
self.nocraft = nocraft
|
||||||
self.noapi, self.nohang = noapi, nohang
|
self.nohang = nohang
|
||||||
self.timeout, self.logreq = timeout, logreq
|
self.timeout, self.logreq = timeout, logreq
|
||||||
self.logresp, self.hexdump = logresp, hexdump
|
self.logresp, self.hexdump = logresp, hexdump
|
||||||
self.http2_framedump = http2_framedump
|
self.http2_framedump = http2_framedump
|
||||||
@ -404,14 +401,13 @@ class Pathod(tcp.TCPServer):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def add_log(self, d):
|
def add_log(self, d):
|
||||||
if not self.noapi:
|
with self.loglock:
|
||||||
with self.loglock:
|
d["id"] = self.logid
|
||||||
d["id"] = self.logid
|
self.log.insert(0, d)
|
||||||
self.log.insert(0, d)
|
if len(self.log) > self.LOGBUF:
|
||||||
if len(self.log) > self.LOGBUF:
|
self.log.pop()
|
||||||
self.log.pop()
|
self.logid += 1
|
||||||
self.logid += 1
|
return d["id"]
|
||||||
return d["id"]
|
|
||||||
|
|
||||||
def clear_log(self):
|
def clear_log(self):
|
||||||
with self.loglock:
|
with self.loglock:
|
||||||
@ -469,9 +465,7 @@ def main(args): # pragma: no cover
|
|||||||
staticdir=args.staticdir,
|
staticdir=args.staticdir,
|
||||||
anchors=args.anchors,
|
anchors=args.anchors,
|
||||||
sizelimit=args.sizelimit,
|
sizelimit=args.sizelimit,
|
||||||
noweb=args.noweb,
|
|
||||||
nocraft=args.nocraft,
|
nocraft=args.nocraft,
|
||||||
noapi=args.noapi,
|
|
||||||
nohang=args.nohang,
|
nohang=args.nohang,
|
||||||
timeout=args.timeout,
|
timeout=args.timeout,
|
||||||
logreq=args.logreq,
|
logreq=args.logreq,
|
||||||
|
@ -74,18 +74,10 @@ def args_pathod(argv, stdout_=sys.stdout, stderr_=sys.stderr):
|
|||||||
default=None,
|
default=None,
|
||||||
type=str,
|
type=str,
|
||||||
help='Size limit of served responses. Understands size suffixes, i.e. 100k.')
|
help='Size limit of served responses. Understands size suffixes, i.e. 100k.')
|
||||||
parser.add_argument(
|
|
||||||
"--noapi", dest='noapi', default=False, action="store_true",
|
|
||||||
help='Disable API.'
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--nohang", dest='nohang', default=False, action="store_true",
|
"--nohang", dest='nohang', default=False, action="store_true",
|
||||||
help='Disable pauses during crafted response generation.'
|
help='Disable pauses during crafted response generation.'
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"--noweb", dest='noweb', default=False, action="store_true",
|
|
||||||
help='Disable both web interface and API.'
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--nocraft",
|
"--nocraft",
|
||||||
dest='nocraft',
|
dest='nocraft',
|
||||||
|
@ -228,6 +228,7 @@ class TestDaemon(PathocTestDaemon):
|
|||||||
|
|
||||||
class TestDaemonHTTP2(PathocTestDaemon):
|
class TestDaemonHTTP2(PathocTestDaemon):
|
||||||
ssl = True
|
ssl = True
|
||||||
|
explain = False
|
||||||
|
|
||||||
if tcp.HAS_ALPN:
|
if tcp.HAS_ALPN:
|
||||||
|
|
||||||
|
@ -23,18 +23,10 @@ class TestPathod(object):
|
|||||||
assert len(p.get_log()) <= p.LOGBUF
|
assert len(p.get_log()) <= p.LOGBUF
|
||||||
|
|
||||||
|
|
||||||
class TestNoWeb(tutils.DaemonTests):
|
|
||||||
noweb = True
|
|
||||||
|
|
||||||
def test_noweb(self):
|
|
||||||
assert self.get("200:da").status_code == 200
|
|
||||||
assert self.getpath("/").status_code == 800
|
|
||||||
|
|
||||||
|
|
||||||
class TestTimeout(tutils.DaemonTests):
|
class TestTimeout(tutils.DaemonTests):
|
||||||
timeout = 0.01
|
timeout = 0.01
|
||||||
|
|
||||||
def test_noweb(self):
|
def test_timeout(self):
|
||||||
# FIXME: Add float values to spec language, reduce test timeout to
|
# FIXME: Add float values to spec language, reduce test timeout to
|
||||||
# increase test performance
|
# increase test performance
|
||||||
# This is a bodge - we have some platform difference that causes
|
# This is a bodge - we have some platform difference that causes
|
||||||
@ -261,8 +253,6 @@ class TestDaemonSSL(CommonTests):
|
|||||||
|
|
||||||
class TestHTTP2(tutils.DaemonTests):
|
class TestHTTP2(tutils.DaemonTests):
|
||||||
ssl = True
|
ssl = True
|
||||||
noweb = True
|
|
||||||
noapi = True
|
|
||||||
nohang = True
|
nohang = True
|
||||||
|
|
||||||
if tcp.HAS_ALPN:
|
if tcp.HAS_ALPN:
|
||||||
|
@ -24,14 +24,13 @@ def treader(bytes):
|
|||||||
|
|
||||||
|
|
||||||
class DaemonTests(object):
|
class DaemonTests(object):
|
||||||
noweb = False
|
|
||||||
noapi = False
|
|
||||||
nohang = False
|
nohang = False
|
||||||
ssl = False
|
ssl = False
|
||||||
timeout = None
|
timeout = None
|
||||||
hexdump = False
|
hexdump = False
|
||||||
ssloptions = None
|
ssloptions = None
|
||||||
nocraft = False
|
nocraft = False
|
||||||
|
explain = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_class(cls):
|
def setup_class(cls):
|
||||||
@ -47,15 +46,13 @@ class DaemonTests(object):
|
|||||||
ssl=cls.ssl,
|
ssl=cls.ssl,
|
||||||
ssloptions=so,
|
ssloptions=so,
|
||||||
sizelimit=1 * 1024 * 1024,
|
sizelimit=1 * 1024 * 1024,
|
||||||
noweb=cls.noweb,
|
|
||||||
noapi=cls.noapi,
|
|
||||||
nohang=cls.nohang,
|
nohang=cls.nohang,
|
||||||
timeout=cls.timeout,
|
timeout=cls.timeout,
|
||||||
hexdump=cls.hexdump,
|
hexdump=cls.hexdump,
|
||||||
nocraft=cls.nocraft,
|
nocraft=cls.nocraft,
|
||||||
logreq=True,
|
logreq=True,
|
||||||
logresp=True,
|
logresp=True,
|
||||||
explain=True
|
explain=cls.explain
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -65,8 +62,7 @@ class DaemonTests(object):
|
|||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
self.d.wait_for_silence()
|
self.d.wait_for_silence()
|
||||||
if not (self.noweb or self.noapi):
|
self.d.clear_log()
|
||||||
self.d.clear_log()
|
|
||||||
|
|
||||||
def _getpath(self, path, params=None):
|
def _getpath(self, path, params=None):
|
||||||
scheme = "https" if self.ssl else "http"
|
scheme = "https" if self.ssl else "http"
|
||||||
|
Loading…
Reference in New Issue
Block a user