diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-21 10:56:30 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-21 10:56:30 +1200 |
commit | 1089a52f3d16c4fef504586cae18a5d324e8d75c (patch) | |
tree | 3616be49d90c63d3366254fa8b6894844c6484c9 /libpathod/rparse.py | |
parent | de00497b4098fece043a1550a94e112829bcbceb (diff) | |
download | mitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.tar.gz mitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.tar.bz2 mitmproxy-1089a52f3d16c4fef504586cae18a5d324e8d75c.zip |
Disconnect, rest refactoring.
Diffstat (limited to 'libpathod/rparse.py')
-rw-r--r-- | libpathod/rparse.py | 13 |
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, |