diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2010-02-24 16:30:00 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2010-02-24 16:30:00 +1300 |
commit | 146a8c6d7c603519f1effc3c7f1a75b1a34cd811 (patch) | |
tree | 69d816f34405989df5dba4f82f11bf35b53c4765 /libmproxy | |
parent | 30dd76e5a4c871df33728be980b83f03a2a3e9f3 (diff) | |
download | mitmproxy-146a8c6d7c603519f1effc3c7f1a75b1a34cd811.tar.gz mitmproxy-146a8c6d7c603519f1effc3c7f1a75b1a34cd811.tar.bz2 mitmproxy-146a8c6d7c603519f1effc3c7f1a75b1a34cd811.zip |
Save a request or response to file.
Ideally, we'd have a nice selection widget with tab completion and the like.
Maybe later...
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/console.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libmproxy/console.py b/libmproxy/console.py index 7a96ec38..aca9ecdf 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import Queue, mailcap, mimetypes, tempfile, os, subprocess, threading +import os.path import cStringIO import urwid.curses_display import urwid @@ -259,6 +260,18 @@ class ConnectionView(urwid.WidgetWrap): self.flow.request.method = i[0].upper() self.master.refresh_connection(self.flow) + def save_connection(self, path): + if self.viewing == self.REQ: + c = self.flow.request + else: + c = self.flow.response + path = os.path.expanduser(path) + f = file(path, "w") + f.write(str(c.headers)) + f.write("\r\n") + f.write(str(c.content)) + f.close() + def edit(self, part): if self.viewing == self.REQ: conn = self.flow.request @@ -328,6 +341,11 @@ class ConnectionView(urwid.WidgetWrap): elif key == "R": self.state.revert(self.flow) self.master.refresh_connection(self.flow) + elif key == "S": + if self.viewing == self.REQ: + self.master.prompt("Save request: ", self.save_connection) + else: + self.master.prompt("Save response: ", self.save_connection) elif key == "v": if self.viewing == self.REQ: conn = self.flow.request @@ -793,6 +811,7 @@ class ConsoleMaster(controller.Master): keys = [ ("b", "toggle hexdump view"), ("e", "edit response/request"), + ("S", "save request or response"), ("v", "view contents in external viewer"), ("tab", "toggle response/request view"), ] |