mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-12-04 12:40:06 +00:00
Tune content viewing to maintain responsiveness:
- Reduce display cutoff to 20k. - Make sure that we only indent the visible part of a JS body, not the whole thing.
This commit is contained in:
parent
585bf9423f
commit
35f4a1c424
@ -6,7 +6,7 @@ import common
|
|||||||
from .. import utils, encoding, flow
|
from .. import utils, encoding, flow
|
||||||
from ..contrib import jsbeautifier
|
from ..contrib import jsbeautifier
|
||||||
|
|
||||||
VIEW_CUTOFF = 1024*100
|
VIEW_CUTOFF = 1024*20
|
||||||
|
|
||||||
VIEW_CONTENT_RAW = 0
|
VIEW_CONTENT_RAW = 0
|
||||||
VIEW_CONTENT_HEX = 1
|
VIEW_CONTENT_HEX = 1
|
||||||
@ -64,21 +64,21 @@ def trailer(clen, txt):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _view_text(content):
|
def _view_text(content, total):
|
||||||
"""
|
"""
|
||||||
Generates a body for a chunk of text.
|
Generates a body for a chunk of text.
|
||||||
"""
|
"""
|
||||||
txt = []
|
txt = []
|
||||||
for i in utils.cleanBin(content[:VIEW_CUTOFF]).splitlines():
|
for i in utils.cleanBin(content).splitlines():
|
||||||
txt.append(
|
txt.append(
|
||||||
urwid.Text(("text", i))
|
urwid.Text(("text", i))
|
||||||
)
|
)
|
||||||
trailer(len(content), txt)
|
trailer(total, txt)
|
||||||
return txt
|
return txt
|
||||||
|
|
||||||
|
|
||||||
def view_raw(hdrs, content):
|
def view_raw(hdrs, content):
|
||||||
txt = _view_text(content)
|
txt = _view_text(content[:VIEW_CUTOFF], len(content))
|
||||||
return "Raw", txt
|
return "Raw", txt
|
||||||
|
|
||||||
|
|
||||||
@ -170,8 +170,8 @@ def view_urlencoded(hdrs, content):
|
|||||||
def view_javascript(hdrs, content):
|
def view_javascript(hdrs, content):
|
||||||
opts = jsbeautifier.default_options()
|
opts = jsbeautifier.default_options()
|
||||||
opts.indent_size = 2
|
opts.indent_size = 2
|
||||||
res = jsbeautifier.beautify(content, opts)
|
res = jsbeautifier.beautify(content[:VIEW_CUTOFF], opts)
|
||||||
return "JavaScript", _view_text(res)
|
return "JavaScript", _view_text(res, len(content))
|
||||||
|
|
||||||
|
|
||||||
def view_image(hdrs, content):
|
def view_image(hdrs, content):
|
||||||
|
Loading…
Reference in New Issue
Block a user