diff options
| author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-24 22:59:20 +1200 |
|---|---|---|
| committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-24 22:59:20 +1200 |
| commit | a747043cc81bd6413b6c85b2517530caf38e8a54 (patch) | |
| tree | be4c45a75f3860d2f6d1f53407426eaf5ac2c5a8 /libpathod | |
| parent | ddda57179adcdab4f005efb90bd1d009819529b8 (diff) | |
| download | mitmproxy-a747043cc81bd6413b6c85b2517530caf38e8a54.tar.gz mitmproxy-a747043cc81bd6413b6c85b2517530caf38e8a54.tar.bz2 mitmproxy-a747043cc81bd6413b6c85b2517530caf38e8a54.zip | |
Use http.read_response to read server response.
Also add a few different output formats, and a verbosity flag.
Diffstat (limited to 'libpathod')
| -rw-r--r-- | libpathod/pathoc.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index e378e863..c2abcaeb 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -4,6 +4,16 @@ import rparse class PathocError(Exception): pass +def print_short(fp, httpversion, code, msg, headers, content): + print >> fp, "%s %s: %s bytes"%(code, msg, len(content)) + + +def print_full(fp, httpversion, code, msg, headers, content): + print >> fp, "HTTP%s/%s %s %s"%(httpversion[0], httpversion[1], code, msg) + print >> fp, headers + print >> fp, content + + class Pathoc(tcp.TCPClient): def __init__(self, ssl, host, port, clientcert): try: @@ -15,7 +25,5 @@ class Pathoc(tcp.TCPClient): r = rparse.parse_request({}, spec) r.serve(self.wfile) self.wfile.flush() - - line = self.rfile.readline() - print line + return http.read_response(self.rfile, r.method, None) |
