diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/nonblocking.py | 8 | ||||
-rw-r--r-- | examples/stub.py | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/examples/nonblocking.py b/examples/nonblocking.py new file mode 100644 index 00000000..ed8cc7c9 --- /dev/null +++ b/examples/nonblocking.py @@ -0,0 +1,8 @@ +import time +from libmproxy.script import concurrent + +@concurrent +def request(context, flow): + print "handle request: %s%s" % (flow.request.host, flow.request.path) + time.sleep(5) + print "start request: %s%s" % (flow.request.host, flow.request.path)
\ No newline at end of file diff --git a/examples/stub.py b/examples/stub.py index 42b2935a..78cbfcf2 100644 --- a/examples/stub.py +++ b/examples/stub.py @@ -14,6 +14,13 @@ def clientconnect(ctx, client_connect): """ ctx.log("clientconnect") +def serverconnect(ctx, server_connection): + """ + Called when the proxy initiates a connection to the target server. Note that a + connection can correspond to multiple HTTP requests + """ + ctx.log("serverconnect") + def request(ctx, flow): """ Called when a client request has been received. |