2015-02-26 18:17:40 +00:00
|
|
|
"""
|
|
|
|
This inline script won't work with --stream SIZE command line option.
|
|
|
|
|
|
|
|
That's because flow.response.stream will be overwritten to True if the
|
|
|
|
command line option exists.
|
|
|
|
"""
|
|
|
|
|
2015-02-26 17:44:47 +00:00
|
|
|
def modify(chunks):
|
|
|
|
"""
|
|
|
|
chunks is a generator that can be used to iterate over all chunks.
|
|
|
|
Each chunk is a (prefix, content, suffix) tuple.
|
|
|
|
For example, in the case of chunked transfer encoding: ("3\r\n","foo","\r\n")
|
|
|
|
"""
|
|
|
|
for prefix, content, suffix in chunks:
|
|
|
|
yield prefix, content.replace("foo","bar"), suffix
|
|
|
|
|
|
|
|
def responseheaders(ctx, flow):
|
|
|
|
flow.response.stream = modify
|
2015-02-26 18:17:40 +00:00
|
|
|
flow.response.stream_large_bodies = 1024 # = 1KB
|