MCPcopy
hub / github.com/mitmproxy/mitmproxy / format_http_flow_list

Function format_http_flow_list

mitmproxy/tools/console/common.py:381–475  ·  view source on GitHub ↗
(
    *,
    render_mode: RenderMode,
    focused: bool,
    marked: str,
    is_replay: bool,
    request_method: str,
    request_scheme: str,
    request_host: str,
    request_path: str,
    request_url: str,
    request_http_version: str,
    request_timestamp: float,
    request_is_push_promise: bool,
    intercepted: bool,
    response_code: int | None,
    response_reason: str | None,
    response_content_length: int | None,
    response_content_type: str | None,
    duration: float | None,
    error_message: str | None,
)

Source from the content-addressed store, hash-verified

379
380@lru_cache(maxsize=800)
381def format_http_flow_list(
382 *,
383 render_mode: RenderMode,
384 focused: bool,
385 marked: str,
386 is_replay: bool,
387 request_method: str,
388 request_scheme: str,
389 request_host: str,
390 request_path: str,
391 request_url: str,
392 request_http_version: str,
393 request_timestamp: float,
394 request_is_push_promise: bool,
395 intercepted: bool,
396 response_code: int | None,
397 response_reason: str | None,
398 response_content_length: int | None,
399 response_content_type: str | None,
400 duration: float | None,
401 error_message: str | None,
402) -> urwid.Widget:
403 req = []
404
405 if render_mode is RenderMode.DETAILVIEW:
406 req.append(fcol(human.format_timestamp(request_timestamp), "highlight"))
407 else:
408 if focused:
409 req.append(fcol(">>", "focus"))
410 else:
411 req.append(fcol(" ", "focus"))
412
413 method_style = HTTP_REQUEST_METHOD_STYLES.get(request_method, "method_other")
414 req.append(fcol(request_method, method_style))
415
416 if request_is_push_promise:
417 req.append(fcol("PUSH_PROMISE", "method_http2_push"))
418
419 preamble_len = sum(x[1] for x in req) + len(req) - 1
420
421 if request_http_version not in ("HTTP/1.0", "HTTP/1.1"):
422 request_url += " " + request_http_version
423 if intercepted and not response_code:
424 url_style = "intercept"
425 elif response_code or error_message:
426 url_style = "text"
427 else:
428 url_style = "title"
429
430 if render_mode is RenderMode.DETAILVIEW:
431 req.append(urwid.Text([(url_style, request_url)]))
432 else:
433 req.append(truncated_plain(request_url, url_style))
434
435 req.append(format_right_indicators(replay=is_replay, marked=marked))
436
437 resp = [("fixed", preamble_len, urwid.Text(""))]
438 if response_code:

Callers

nothing calls this directly

Calls 8

fcolFunction · 0.85
truncated_plainFunction · 0.85
format_right_indicatorsFunction · 0.85
format_http_content_typeFunction · 0.85
format_sizeFunction · 0.85
format_durationFunction · 0.85
appendMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…