aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod/rparse.py
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2012-06-21 10:56:30 +1200
committerAldo Cortesi <aldo@nullcube.com>2012-06-21 10:56:30 +1200
commit1089a52f3d16c4fef504586cae18a5d324e8d75c (patch)
tree3616be49d90c63d3366254fa8b6894844c6484c9 /libpathod/rparse.py
parentde00497b4098fece043a1550a94e112829bcbceb (diff)
downloadmitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.tar.gz
mitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.tar.bz2
mitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.zip
Disconnect, rest refactoring.
Diffstat (limited to 'libpathod/rparse.py')
-rw-r--r--libpathod/rparse.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index 677c6b54..47084520 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -390,6 +390,9 @@ class Response:
return ret
def write_values(self, fp, vals, actions, sofar=0, skip=0, blocksize=BLOCKSIZE):
+ """
+ Return True if connection should disconnect.
+ """
while vals:
part = vals.pop()
for i in range(skip, len(part), blocksize):
@@ -401,18 +404,15 @@ class Response:
if p[1] == "pause":
fp.write(d[:offset])
time.sleep(p[2])
- self.write_values(
+ return self.write_values(
fp, vals, actions,
sofar=sofar+offset,
skip=i+offset,
blocksize=blocksize
)
- return
elif p[1] == "disconnect":
fp.write(d[:offset])
- fp.finish()
- fp.connection.stream.close()
- return
+ return True
fp.write(d)
sofar += len(d)
skip = 0
@@ -447,9 +447,10 @@ class Response:
vals.reverse()
actions = self.ready_actions(self.length(), self.actions)
actions.reverse()
- self.write_values(fp, vals, actions[:])
+ disconnect = self.write_values(fp, vals, actions[:])
duration = time.time() - started
return dict(
+ disconnect = disconnect,
started = started,
duration = duration,
actions = actions,