aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/stream_modify.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/stream_modify.py b/examples/stream_modify.py
new file mode 100644
index 00000000..517f730a
--- /dev/null
+++ b/examples/stream_modify.py
@@ -0,0 +1,11 @@
+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