diff --git a/README b/README index af7aa48a8..31c205a2b 100644 --- a/README +++ b/README @@ -6,6 +6,7 @@ things programmatically. By default, mitmproxy starts up with a mutt-like interactive curses interface - the help page (which you can view by pressing "?") should tell you everything you need to know. Note that requests and responses are stored in-memory until +* A recent [Python](http://www.python.org) interpreter. you delete them, so leaving mitmproxy running indefinitely or requesting very large amounts of data through it is a bad idea. diff --git a/libmproxy/console.py b/libmproxy/console.py index 7a96ec38a..aca9ecdfb 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -14,6 +14,7 @@ # along with this program. If not, see . 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"), ]