A new interface for reply

Reply is now explicit - it's no longer a callable itself. Instead, we have:

    reply.kill()            - kill the flow
    reply.ack()             - ack, but don't send anything
    reply.send(message)     - send a response

This is part of an incremental move to detach reply from our flow objects,
and unify the script and handler interfaces.
This commit is contained in:
Aldo Cortesi
2016-06-08 10:44:20 +12:00
parent 982077ec31
commit a388ddfd78
6 changed files with 28 additions and 40 deletions

View File

@@ -16,7 +16,7 @@ def request(context, flow):
"HTTP/1.1", 200, "OK",
Headers(Content_Type="text/html"),
"helloworld")
flow.reply(resp)
flow.reply.send(resp)
# Method 2: Redirect the request to a different server
if flow.request.pretty_host.endswith("example.org"):

View File

@@ -134,5 +134,5 @@ def next_layer(context, next_layer):
# We don't intercept - reply with a pass-through layer and add a "skipped" entry.
context.log("TLS passthrough for %s" % repr(next_layer.server_conn.address), "info")
next_layer_replacement = RawTCPLayer(next_layer.ctx, logging=False)
next_layer.reply(next_layer_replacement)
next_layer.reply.send(next_layer_replacement)
context.tls_strategy.record_skipped(server_address)