mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 10:26:23 +00:00
wip - content copy is working, header representation is not
This commit is contained in:
parent
44a5070bf5
commit
34d355a62b
@ -1,5 +1,6 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
import urwid
|
import urwid
|
||||||
|
import pyperclip
|
||||||
from . import common
|
from . import common
|
||||||
|
|
||||||
def _mkhelp():
|
def _mkhelp():
|
||||||
@ -136,6 +137,11 @@ class ConnectionItem(common.WWrap):
|
|||||||
self.state.last_saveload,
|
self.state.last_saveload,
|
||||||
self.master.server_playback_path
|
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):
|
def keypress(self, (maxcol,), key):
|
||||||
key = common.shortcuts(key)
|
key = common.shortcuts(key)
|
||||||
@ -202,6 +208,16 @@ class ConnectionItem(common.WWrap):
|
|||||||
self.master.run_script_once,
|
self.master.run_script_once,
|
||||||
self.flow
|
self.flow
|
||||||
)
|
)
|
||||||
|
elif key == "g":
|
||||||
|
#copy flow part
|
||||||
|
self.master.prompt_onekey(
|
||||||
|
"Copy Response",
|
||||||
|
(
|
||||||
|
("content", "c"),
|
||||||
|
("headers", "h"),
|
||||||
|
),
|
||||||
|
self.server_copy_response,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
return key
|
return key
|
||||||
|
|
||||||
|
@ -953,6 +953,21 @@ class HTTPFlow(Flow):
|
|||||||
c += self.response.replace(pattern, repl, *args, **kwargs)
|
c += self.response.replace(pattern, repl, *args, **kwargs)
|
||||||
return c
|
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):
|
class HttpAuthenticationError(Exception):
|
||||||
def __init__(self, auth_headers=None):
|
def __init__(self, auth_headers=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user