From f89a5235d36db8c82ec608ba1f39809d2a355384 Mon Sep 17 00:00:00 2001 From: Marcelo Glezer Date: Wed, 14 Jan 2015 10:52:52 -0300 Subject: wip - content copy is working, header representation is not --- libmproxy/console/flowlist.py | 16 ++++++++++++++++ libmproxy/protocol/http.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) (limited to 'libmproxy') diff --git a/libmproxy/console/flowlist.py b/libmproxy/console/flowlist.py index 102fa7b9..cdb4af49 100644 --- a/libmproxy/console/flowlist.py +++ b/libmproxy/console/flowlist.py @@ -1,5 +1,6 @@ from __future__ import absolute_import import urwid +import pyperclip from . import common def _mkhelp(): @@ -138,6 +139,11 @@ class ConnectionItem(common.WWrap): self.state.last_saveload, self.master.server_playback_path ) + def server_copy_response(self, k): + if k == "c": + pyperclip.copy(self.flow.response_content()) + elif k == "t": + pyperclip.copy(self.flow.response_headers()) def keypress(self, (maxcol,), key): key = common.shortcuts(key) @@ -204,6 +210,16 @@ class ConnectionItem(common.WWrap): self.master.run_script_once, self.flow ) + elif key == "g": + #copy flow part + self.master.prompt_onekey( + "Copy Response", + ( + ("content", "c"), + ("headers", "h"), + ), + self.server_copy_response, + ) else: return key diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index bebb4f7b..04e3fe40 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -953,6 +953,21 @@ class HTTPFlow(Flow): c += self.response.replace(pattern, repl, *args, **kwargs) return c + def response_content(self): + s = "[No Content]" + with decoded(self.response): + s = self.response.content + return s + + def response_headers(self): + with decoded(self.response): + sh = "" + for i in self.flow.response.headers: + v = self.flow.response.headers[i] + for j in v: + sh += str(i)+"="+str(v[j])+"\n" + return sh + class HttpAuthenticationError(Exception): def __init__(self, auth_headers=None): -- cgit v1.2.3