diff options
Diffstat (limited to 'libpathod')
-rw-r--r-- | libpathod/language.py | 5 | ||||
-rw-r--r-- | libpathod/pathoc.py | 6 | ||||
-rw-r--r-- | libpathod/pathod.py | 6 |
3 files changed, 14 insertions, 3 deletions
diff --git a/libpathod/language.py b/libpathod/language.py index 654dc37e..3c545fb9 100644 --- a/libpathod/language.py +++ b/libpathod/language.py @@ -805,8 +805,9 @@ class _Message(object): vals.append(self.body.value.get_generator(settings)) return vals - def freeze(self, settings): - return self.__class__([i.freeze(settings) for i in self.tokens]) + def freeze(self, settings, request_host=None): + r = self.resolve(settings, request_host=None) + return self.__class__([i.freeze(settings) for i in r.tokens]) def __repr__(self): return self.spec() diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index b4020a3f..dcee353f 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -62,6 +62,9 @@ class Pathoc(tcp.TCPClient): print >> fp, "File access error: %s"%v return + if explain: + r = r.freeze(self.settings, self.host) + resp, req = None, None if showreq: self.wfile.start_log() @@ -83,6 +86,9 @@ class Pathoc(tcp.TCPClient): if req: if ignorecodes and resp and resp[1] in ignorecodes: return + if explain: + print >> fp, ">> Spec:", r.spec() + if showreq: self._show(fp, ">> Request", self.wfile.get_log(), hexdump) 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() |