aboutsummaryrefslogtreecommitdiffstats
path: root/libpathod
diff options
context:
space:
mode:
Diffstat (limited to 'libpathod')
-rw-r--r--libpathod/pathoc.py15
-rw-r--r--libpathod/rparse.py4
2 files changed, 15 insertions, 4 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py
index 57bff46b..b283c94e 100644
--- a/libpathod/pathoc.py
+++ b/libpathod/pathoc.py
@@ -1,5 +1,6 @@
import sys, os
from netlib import tcp, http
+import netlib.utils
import rparse, utils
class PathocError(Exception): pass
@@ -49,15 +50,25 @@ class Pathoc(tcp.TCPClient):
for i in reqs:
try:
r = rparse.parse_request(self.settings, i)
+ if showreq:
+ self.wfile.start_log()
req = r.serve(self.wfile, None, self.host)
if explain:
- print >> fp, ">>", req["method"], repr(req["path"])
+ print >> fp, ">> ", req["method"], repr(req["path"])
for a in req["actions"]:
print >> fp, "\t",
for x in a:
print >> fp, x,
print >> fp
- print req
+ if showreq:
+ data = self.wfile.get_log()
+ if hexdump:
+ print >> fp, ">> Request (hex dump):"
+ for line in netlib.utils.hexdump(data):
+ print >> fp, "\t%s %s %s"%line
+ else:
+ print >> fp, ">> Request (unprintables escaped):"
+ print >> fp, netlib.utils.cleanBin(data)
self.wfile.flush()
resp = http.read_response(self.rfile, r.method, None)
except rparse.ParseException, v:
diff --git a/libpathod/rparse.py b/libpathod/rparse.py
index 3eaf2569..53878b97 100644
--- a/libpathod/rparse.py
+++ b/libpathod/rparse.py
@@ -653,7 +653,7 @@ class Response(Message):
ShortcutLocation,
Raw
)
- logattrs = ["code", "version"]
+ logattrs = ["code", "version", "body"]
def __init__(self):
Message.__init__(self)
self.code = 200
@@ -691,7 +691,7 @@ class Request(Message):
ShortcutContentType,
Raw
)
- logattrs = ["method", "path"]
+ logattrs = ["method", "path", "body"]
def __init__(self):
Message.__init__(self)
self.method = None