From 3f50930dc06a980ac5dcf012fa23ecc0a70ce1b4 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 31 Oct 2012 11:23:53 +1300 Subject: Use .freeze to implement the -e explain flags for pathod and pathoc. This now prints (in pathoc) or logs (in pathod) a frozen specification that includes an expanded record of all generated values and locations. --- libpathod/pathod.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libpathod/pathod.py') diff --git a/libpathod/pathod.py b/libpathod/pathod.py index fb6a7725..bc5a1825 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -28,6 +28,9 @@ class PathodHandler(tcp.BaseHandler): ) return False, log + if self.server.explain: + crafted = crafted.freeze(self.server.request_settings, None) + print crafted response_log = language.serve(crafted, self.wfile, self.server.request_settings, None) log = dict( type = "crafted", @@ -171,7 +174,7 @@ class Pathod(tcp.TCPServer): def __init__( self, addr, ssloptions=None, craftanchor="/p/", staticdir=None, anchors=None, sizelimit=None, noweb=False, nocraft=False, noapi=False, nohang=False, - timeout=None, logreq=False, logresp=False, hexdump=False + timeout=None, logreq=False, logresp=False, explain=False, hexdump=False ): """ addr: (address, port) tuple. If port is 0, a free port will be @@ -192,6 +195,7 @@ class Pathod(tcp.TCPServer): self.sizelimit = sizelimit self.noweb, self.nocraft, self.noapi, self.nohang = noweb, nocraft, noapi, nohang self.timeout, self.logreq, self.logresp, self.hexdump = timeout, logreq, logresp, hexdump + self.explain = explain if not noapi: app.api() -- cgit v1.2.3