mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Make actions at end of message work.
This commit is contained in:
parent
8f0ebb405d
commit
cb09488dc8
@ -86,6 +86,15 @@ def write_values(fp, vals, actions, sofar=0, skip=0, blocksize=BLOCKSIZE):
|
||||
send_chunk(fp, a[2], blocksize, 0, len(a[2]))
|
||||
send_chunk(fp, v, blocksize, offset, len(v))
|
||||
sofar += len(v)
|
||||
# Remainders
|
||||
while actions:
|
||||
a = actions.pop()
|
||||
if a[1] == "pause":
|
||||
time.sleep(a[2])
|
||||
elif a[1] == "disconnect":
|
||||
return True
|
||||
elif a[1] == "inject":
|
||||
send_chunk(fp, a[2], blocksize, 0, len(a[2]))
|
||||
except tcp.NetLibDisconnect: # pragma: no cover
|
||||
return True
|
||||
|
||||
@ -434,12 +443,7 @@ class DisconnectAt:
|
||||
@classmethod
|
||||
def expr(klass):
|
||||
e = pp.Literal("d").suppress()
|
||||
e += e + pp.MatchFirst(
|
||||
[
|
||||
v_integer,
|
||||
pp.Literal("r")
|
||||
]
|
||||
)
|
||||
e += Offset
|
||||
return e.setParseAction(lambda x: klass(*x))
|
||||
|
||||
|
||||
|
@ -391,6 +391,20 @@ class TestWriteValues:
|
||||
rparse.write_values(s, tst[:], [(1, "pause", 0)], blocksize=i)
|
||||
assert s.getvalue() == "".join(tst)
|
||||
|
||||
def test_write_values_after(self):
|
||||
s = cStringIO.StringIO()
|
||||
r = rparse.parse_response({}, "400:da")
|
||||
r.serve(s, None)
|
||||
|
||||
s = cStringIO.StringIO()
|
||||
r = rparse.parse_response({}, "400:p0,a")
|
||||
r.serve(s, None)
|
||||
|
||||
s = cStringIO.StringIO()
|
||||
r = rparse.parse_response({}, "400:ia,'xx'")
|
||||
r.serve(s, None)
|
||||
assert s.getvalue().endswith('xx')
|
||||
|
||||
|
||||
def test_ready_actions():
|
||||
x = [(0, 5)]
|
||||
|
Loading…
Reference in New Issue
Block a user