Controls the length of URL displayed using the -d option (#1903)
This commit is contained in:
parent
2335a70b79
commit
3ea76a7f3e
|
@ -2,6 +2,7 @@ import itertools
|
|||
import sys
|
||||
|
||||
import click
|
||||
import shutil
|
||||
|
||||
import typing # noqa
|
||||
|
||||
|
@ -124,6 +125,9 @@ class Dumper:
|
|||
url = flow.request.pretty_url
|
||||
else:
|
||||
url = flow.request.url
|
||||
terminalWidthLimit = max(shutil.get_terminal_size()[0] - 25, 50)
|
||||
if self.flow_detail < 1 and len(url) > terminalWidthLimit:
|
||||
url = url[:terminalWidthLimit] + "…"
|
||||
url = click.style(strutils.escape_control_characters(url), bold=True)
|
||||
|
||||
http_version = ""
|
||||
|
|
|
@ -7,6 +7,7 @@ from mitmproxy.addons import dumper
|
|||
from mitmproxy import exceptions
|
||||
from mitmproxy.tools import dump
|
||||
from mitmproxy import http
|
||||
import shutil
|
||||
import mock
|
||||
|
||||
|
||||
|
@ -129,6 +130,14 @@ def test_echo_request_line():
|
|||
assert "nonstandard" in sio.getvalue()
|
||||
sio.truncate(0)
|
||||
|
||||
ctx.configure(d, flow_detail=0, showhost=True)
|
||||
f = tflow.tflow(client_conn=None, server_conn=True, resp=True)
|
||||
terminalWidth = max(shutil.get_terminal_size()[0] - 25, 50)
|
||||
f.request.url = "http://address:22/" + ("x" * terminalWidth) + "textToBeTruncated"
|
||||
d._echo_request_line(f)
|
||||
assert "textToBeTruncated" not in sio.getvalue()
|
||||
sio.truncate(0)
|
||||
|
||||
|
||||
class TestContentView:
|
||||
@mock.patch("mitmproxy.contentviews.auto.ViewAuto.__call__")
|
||||
|
|
Loading…
Reference in New Issue