diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 23:57:18 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-07-24 23:57:18 +1200 |
commit | 64ef0a4561058de4ca7309767e89366bc1c7502f (patch) | |
tree | 435cae8ea1103ad6e81933516a6498607ef97999 | |
parent | cb09488dc8e4b03706a9cc1fa71284a2f7ce33c1 (diff) | |
download | mitmproxy-64ef0a4561058de4ca7309767e89366bc1c7502f.tar.gz mitmproxy-64ef0a4561058de4ca7309767e89366bc1c7502f.tar.bz2 mitmproxy-64ef0a4561058de4ca7309767e89366bc1c7502f.zip |
Swap the offset, seconds arguments for the pause operator.
This makes it uniform with the other operators.s
-rw-r--r-- | libpathod/rparse.py | 8 | ||||
-rw-r--r-- | libpathod/templates/docs_lang.html | 4 | ||||
-rw-r--r-- | libpathod/templates/docs_pathod.html | 8 | ||||
-rw-r--r-- | test/test_pathoc.py | 2 | ||||
-rw-r--r-- | test/test_rparse.py | 14 |
5 files changed, 18 insertions, 18 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py index 8b19a1d2..ab657974 100644 --- a/libpathod/rparse.py +++ b/libpathod/rparse.py @@ -413,20 +413,20 @@ class Method: class PauseAt: - def __init__(self, seconds, offset): - self.seconds, self.offset = seconds, offset + def __init__(self, offset, seconds): + self.offset, self.seconds = offset, seconds @classmethod def expr(klass): e = pp.Literal("p").suppress() + e += Offset + e += pp.Literal(",").suppress() e += pp.MatchFirst( [ v_integer, pp.Literal("f") ] ) - e += pp.Literal(",").suppress() - e += Offset return e.setParseAction(lambda x: klass(*x)) def accept(self, settings, r): diff --git a/libpathod/templates/docs_lang.html b/libpathod/templates/docs_lang.html index 4325ef39..9999282d 100644 --- a/libpathod/templates/docs_lang.html +++ b/libpathod/templates/docs_lang.html @@ -66,7 +66,7 @@ </tr> <tr> - <td> pSECONDS,<a href="#offsetspec">OFFSET</a> </td> + <td> p<a href="#offsetspec">OFFSET</a>,SECONDS </td> <td> Pause for SECONDS seconds after OFFSET bytes. SECONDS can be an integer or "f" to pause forever. @@ -135,7 +135,7 @@ </tr> <tr> - <td> pSECONDS,<a href="#offsetspec">OFFSET</a> </td> + <td> p<a href="#offsetspec">OFFSET</a>,SECONDS </td> <td> Pause for SECONDS seconds after OFFSET bytes. SECONDS can be an integer or "f" to pause forever. diff --git a/libpathod/templates/docs_pathod.html b/libpathod/templates/docs_pathod.html index 977642c6..1c8f01c7 100644 --- a/libpathod/templates/docs_pathod.html +++ b/libpathod/templates/docs_pathod.html @@ -92,19 +92,19 @@ various other goodies. Try it by visiting the server root:</p> for 120 seconds after sending 50 bytes (counted from the first byte of the HTTP response):</p> - <pre class="example">200:b@1m:p120,50</pre> + <pre class="example">200:b@1m:p50,120</pre> <p>If that's not long enough, we can tell pathod to hang forever:</p> - <pre class="example">200:b@1m:p120,f</pre> + <pre class="example">200:b@1m:pf,120</pre> <p>Or to send all data, and then hang without disconnecting:</p> - <pre class="example">200:b@1m:p120,a</pre> + <pre class="example">200:b@1m:pa,120</pre> <p>We can also ask pathod to hang randomly:</p> - <pre class="example">200:b@1m:pr,a</pre> + <pre class="example">200:b@1m:pr,10</pre> <p>There is a similar mechanism for dropping connections mid-response. So, we can tell pathod to disconnect after sending 50 bytes:</p> diff --git a/test/test_pathoc.py b/test/test_pathoc.py index 15493e96..3cd07649 100644 --- a/test/test_pathoc.py +++ b/test/test_pathoc.py @@ -31,7 +31,7 @@ class TestDaemon: s = cStringIO.StringIO() c.print_requests( - ["get:'/p/200:p10,0'"], True, True, s + ["get:'/p/200:p0,10'"], True, True, s ) assert "Timeout" in s.getvalue() diff --git a/test/test_rparse.py b/test/test_rparse.py index 634eb6a7..57520176 100644 --- a/test/test_rparse.py +++ b/test/test_rparse.py @@ -226,13 +226,13 @@ class TestPauses: assert v.seconds == 10 assert v.offset == 10 - v = e.parseString("pf,10")[0] + v = e.parseString("p10,f")[0] assert v.seconds == "f" - v = e.parseString("pf,r")[0] + v = e.parseString("pr,f")[0] assert v.offset == "r" - v = e.parseString("pf,a")[0] + v = e.parseString("pa,f")[0] assert v.offset == "a" def test_request(self): @@ -311,15 +311,15 @@ class TestParseResponse: assert utils.get_header("foo", r.headers) def test_parse_pause_before(self): - r = rparse.parse_response({}, "400:p10,0") + r = rparse.parse_response({}, "400:p0,10") assert (0, "pause", 10) in r.actions def test_parse_pause_after(self): - r = rparse.parse_response({}, "400:p10,a") + r = rparse.parse_response({}, "400:pa,10") assert ("a", "pause", 10) in r.actions def test_parse_pause_random(self): - r = rparse.parse_response({}, "400:p10,r") + r = rparse.parse_response({}, "400:pr,10") assert ("r", "pause", 10) in r.actions def test_parse_stress(self): @@ -397,7 +397,7 @@ class TestWriteValues: r.serve(s, None) s = cStringIO.StringIO() - r = rparse.parse_response({}, "400:p0,a") + r = rparse.parse_response({}, "400:pa,0") r.serve(s, None) s = cStringIO.StringIO() |