MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / _get_content_view

Method _get_content_view

mitmproxy/tools/console/flowview.py:343–373  ·  view source on GitHub ↗
(
        self, viewmode: str, max_lines: int, _
    )

Source from the content-addressed store, hash-verified

341
342 @lru_cache(maxsize=200)
343 def _get_content_view(
344 self, viewmode: str, max_lines: int, _
345 ) -> tuple[str, list[urwid.Text]]:
346 message: http.Message = self._get_content_view_message
347 self._get_content_view_message = None # type: ignore[assignment]
348
349 pretty = contentviews.prettify_message(message, self.flow, viewmode)
350 cut_off = strutils.cut_after_n_lines(pretty.text, max_lines)
351
352 chunks = mitmproxy_rs.syntax_highlight.highlight(
353 cut_off,
354 language=pretty.syntax_highlight,
355 )
356
357 text_objects = [urwid.Text(chunks)]
358 if len(cut_off) < len(pretty.text):
359 text_objects.append(
360 urwid.Text(
361 [
362 (
363 "highlight",
364 "Stopped displaying data after %d lines. Press "
365 % max_lines,
366 ),
367 ("key", "f"),
368 ("highlight", " to load all data."),
369 ]
370 )
371 )
372
373 return f"{pretty.view_name} {pretty.description}", text_objects
374
375 def conn_text(self, conn):
376 if conn:

Callers 1

content_viewMethod · 0.95

Calls 2

highlightMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected