mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
fix #842
This commit is contained in:
parent
354f84c4c8
commit
5d332e7218
@ -1,8 +1,9 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, division
|
||||
import os
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
import math
|
||||
import urwid
|
||||
|
||||
from netlib import odict
|
||||
@ -207,10 +208,26 @@ class FlowView(tabs.Tabs):
|
||||
if description == "No content" and isinstance(message, HTTPRequest):
|
||||
description = "No request content (press tab to view response)"
|
||||
|
||||
# If the users has a wide terminal, he gets fewer lines; this should not be an issue.
|
||||
chars_per_line = 80
|
||||
max_chars = max_lines * chars_per_line
|
||||
total_chars = 0
|
||||
text_objects = []
|
||||
for line in lines:
|
||||
text_objects.append(urwid.Text(line))
|
||||
if len(text_objects) == max_lines:
|
||||
txt = []
|
||||
for (style, text) in line:
|
||||
if total_chars + len(text) > max_chars:
|
||||
text = text[:max_chars-total_chars]
|
||||
txt.append((style, text))
|
||||
total_chars += len(text)
|
||||
if total_chars == max_chars:
|
||||
break
|
||||
|
||||
# round up to the next line.
|
||||
total_chars = int(math.ceil(total_chars / chars_per_line) * chars_per_line)
|
||||
|
||||
text_objects.append(urwid.Text(txt))
|
||||
if total_chars == max_chars:
|
||||
text_objects.append(urwid.Text([
|
||||
("highlight", "Stopped displaying data after %d lines. Press " % max_lines),
|
||||
("key", "f"),
|
||||
|
@ -17,18 +17,15 @@ import json
|
||||
import logging
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import lxml.html
|
||||
import lxml.etree
|
||||
from PIL import Image
|
||||
from PIL.ExifTags import TAGS
|
||||
import html2text
|
||||
import six
|
||||
|
||||
from netlib.odict import ODict
|
||||
from netlib import encoding
|
||||
from netlib.utils import clean_bin, hexdump, urldecode, multipartdecode, parse_content_type
|
||||
|
||||
from . import utils
|
||||
from .exceptions import ContentViewException
|
||||
from .contrib import jsbeautifier
|
||||
@ -485,6 +482,12 @@ content_types_map = {}
|
||||
view_prompts = []
|
||||
|
||||
|
||||
def get(name):
|
||||
for i in views:
|
||||
if i.name == name:
|
||||
return i
|
||||
|
||||
|
||||
def get_by_shortcut(c):
|
||||
for i in views:
|
||||
if i.prompt[1] == c:
|
||||
@ -543,11 +546,6 @@ if pyamf:
|
||||
if ViewProtobuf.is_available():
|
||||
add(ViewProtobuf())
|
||||
|
||||
def get(name):
|
||||
for i in views:
|
||||
if i.name == name:
|
||||
return i
|
||||
|
||||
|
||||
def safe_to_print(lines, encoding="utf8"):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user