Version 0.2.5
This commit is contained in:
parent
0b6a63ddbb
commit
1acaeccf5e
14 changed files with 119 additions and 11 deletions
|
@ -54,6 +54,8 @@ def _code_helper(line, func, copy=True):
|
|||
args = shlex.split(line)
|
||||
if not args:
|
||||
s = clipboard.paste()
|
||||
print 'Will decode:'
|
||||
print printable_data(s)
|
||||
s = func(s)
|
||||
if copy:
|
||||
try:
|
||||
|
|
|
@ -124,7 +124,7 @@ def list_int_macros(line):
|
|||
running = []
|
||||
not_running = []
|
||||
for macro in loaded_int_macros:
|
||||
if macro.name in active_intercepting_macros():
|
||||
if macro.name in [m.name for m in active_intercepting_macros()]:
|
||||
running.append(macro)
|
||||
else:
|
||||
not_running.append(macro)
|
||||
|
|
|
@ -212,7 +212,11 @@ def intercept(line):
|
|||
editor = 'vi'
|
||||
if 'EDITOR' in os.environ:
|
||||
editor = os.environ['EDITOR']
|
||||
subprocess.call([editor, to_edit])
|
||||
additional_args = []
|
||||
if editor == 'vim':
|
||||
# prevent adding additional newline
|
||||
additional_args.append('-b')
|
||||
subprocess.call([editor, to_edit] + additional_args)
|
||||
stdscr.clear()
|
||||
deferred.callback(None)
|
||||
finally:
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import crochet
|
||||
import datetime
|
||||
import json
|
||||
import pappyproxy
|
||||
import pygments
|
||||
import pprint
|
||||
import shlex
|
||||
|
||||
from pappyproxy.console import load_reqlist, print_table, print_request_rows, get_req_data_row
|
||||
|
@ -9,6 +12,8 @@ from pappyproxy.http import Request
|
|||
from twisted.internet import defer
|
||||
from pappyproxy.plugin import main_context_ids
|
||||
from pappyproxy.colors import Colors, Styles, verb_color, scode_color, path_formatter, host_color
|
||||
from pygments.formatters import TerminalFormatter
|
||||
from pygments.lexers.data import JsonLexer
|
||||
|
||||
###################
|
||||
## Helper functions
|
||||
|
@ -91,6 +96,17 @@ def print_tree(tree):
|
|||
# Prints a tree. Takes in a sorted list of path tuples
|
||||
_print_tree_helper(tree, 0, [])
|
||||
|
||||
def pretty_print_body(fmt, body):
|
||||
if fmt.lower() == 'json':
|
||||
try:
|
||||
d = json.loads(body.strip())
|
||||
except:
|
||||
raise PappyException('Body could not be parsed as JSON')
|
||||
s = json.dumps(d, indent=4, sort_keys=True)
|
||||
print pygments.highlight(s, JsonLexer(), TerminalFormatter())
|
||||
else:
|
||||
raise PappyException('%s is not a valid format' % fmt)
|
||||
|
||||
def _get_tree_prefix(depth, print_bars, last):
|
||||
if depth == 0:
|
||||
return u''
|
||||
|
@ -247,6 +263,22 @@ def view_request_bytes(line):
|
|||
if len(reqs) > 1:
|
||||
print '-'*30
|
||||
print ''
|
||||
|
||||
@crochet.wait_for(timeout=None)
|
||||
@defer.inlineCallbacks
|
||||
def pretty_print_request(line):
|
||||
"""
|
||||
Print the body of the request pretty printed.
|
||||
Usage: pretty_print_request <format> <reqid(s)>
|
||||
"""
|
||||
args = shlex.split(line)
|
||||
if len(args) < 2:
|
||||
raise PappyException("Usage: pretty_print_request <format> <reqid(s)>")
|
||||
reqids = args[1]
|
||||
|
||||
reqs = yield load_reqlist(reqids)
|
||||
for req in reqs:
|
||||
pretty_print_body(args[0], req.body)
|
||||
|
||||
@crochet.wait_for(timeout=None)
|
||||
@defer.inlineCallbacks
|
||||
|
@ -297,6 +329,25 @@ def view_response_bytes(line):
|
|||
else:
|
||||
print "Request %s does not have a response" % req.reqid
|
||||
|
||||
@crochet.wait_for(timeout=None)
|
||||
@defer.inlineCallbacks
|
||||
def pretty_print_response(line):
|
||||
"""
|
||||
Print the body of the request pretty printed.
|
||||
Usage: pretty_print_request <format> <reqid(s)>
|
||||
"""
|
||||
args = shlex.split(line)
|
||||
if len(args) < 2:
|
||||
raise PappyException("Usage: pretty_print_request <format> <reqid(s)>")
|
||||
reqids = args[1]
|
||||
|
||||
reqs = yield load_reqlist(reqids)
|
||||
for req in reqs:
|
||||
if req.response:
|
||||
pretty_print_body(args[0], req.response.body)
|
||||
else:
|
||||
print 'No response associated with request %s' % req.reqid
|
||||
|
||||
@crochet.wait_for(timeout=None)
|
||||
@defer.inlineCallbacks
|
||||
def dump_response(line):
|
||||
|
@ -345,9 +396,11 @@ def load_cmds(cmd):
|
|||
'view_request_headers': (view_request_headers, None),
|
||||
'view_full_request': (view_full_request, None),
|
||||
'view_request_bytes': (view_request_bytes, None),
|
||||
'pretty_print_request': (pretty_print_request, None),
|
||||
'view_response_headers': (view_response_headers, None),
|
||||
'view_full_response': (view_full_response, None),
|
||||
'view_response_bytes': (view_response_bytes, None),
|
||||
'pretty_print_response': (pretty_print_response, None),
|
||||
'site_map': (site_map, None),
|
||||
'dump_response': (dump_response, None),
|
||||
})
|
||||
|
@ -357,9 +410,11 @@ def load_cmds(cmd):
|
|||
('view_request_headers', 'vhq'),
|
||||
('view_full_request', 'vfq'),
|
||||
('view_request_bytes', 'vbq'),
|
||||
('pretty_print_request', 'ppq'),
|
||||
('view_response_headers', 'vhs'),
|
||||
('view_full_response', 'vfs'),
|
||||
('view_response_bytes', 'vbs'),
|
||||
('pretty_print_response', 'pps'),
|
||||
('site_map', 'sm'),
|
||||
#('dump_response', 'dr'),
|
||||
])
|
||||
|
|
|
@ -119,6 +119,7 @@ def submit_current_buffer():
|
|||
full_request = '\n'.join(curbuf)
|
||||
commdata = {'action': 'submit',
|
||||
'full_message': base64.b64encode(full_request),
|
||||
'tags': ['repeater'],
|
||||
'port': int(vim.eval("s:repport")),
|
||||
'host': vim.eval("s:rephost")}
|
||||
if vim.eval("s:repisssl") == '1':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue