aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_rparse.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-07-23 10:47:33 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-07-23 10:47:33 +1200
commit204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1 (patch)
tree7880ac1b92b5b3e45ab5f93d67cd70f3da48fa59 /test/test_rparse.py
parent32bd16aa3175b2dd156da3158105d3f82ab65642 (diff)
downloadmitmproxy-204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1.tar.gz
mitmproxy-204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1.tar.bz2
mitmproxy-204a556aa7dbfd37daeb6605318ebc4b7ae8c6b1.zip
Add function for effective length calculation when actions are present.
Diffstat (limited to 'test/test_rparse.py')
-rw-r--r--test/test_rparse.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test_rparse.py b/test/test_rparse.py
index 23c9b3e6..0cb3e373 100644
--- a/test/test_rparse.py
+++ b/test/test_rparse.py
@@ -433,6 +433,36 @@ class TestResponse:
testlen(rparse.parse_response({}, "400'msg':h'foo'='bar'"))
testlen(rparse.parse_response({}, "400'msg':h'foo'='bar':b@100b"))
+ def test_effective_length(self):
+ def testlen(x, actions):
+ s = cStringIO.StringIO()
+ x.serve(s)
+ assert x.effective_length(actions) == len(s.getvalue())
+ actions = [
+
+ ]
+ r = rparse.parse_response({}, "400'msg':b@100")
+
+ actions = [
+ (0, "disconnect"),
+ ]
+ r.actions = actions
+ testlen(r, actions)
+
+ actions = [
+ (0, "disconnect"),
+ (0, "inject", "foo")
+ ]
+ r.actions = actions
+ testlen(r, actions)
+
+ actions = [
+ (0, "inject", "foo")
+ ]
+ r.actions = actions
+ testlen(r, actions)
+
+
def test_read_file():
tutils.raises(rparse.FileAccessDenied, rparse.read_file, {}, "=/foo")