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

Method __init__

mitmproxy/http.py:1020–1053  ·  view source on GitHub ↗
(
        self,
        http_version: bytes,
        status_code: int,
        reason: bytes,
        headers: Headers | tuple[tuple[bytes, bytes], ...],
        content: bytes | None,
        trailers: None | Headers | tuple[tuple[bytes, bytes], ...],
        timestamp_start: float,
        timestamp_end: float | None,
    )

Source from the content-addressed store, hash-verified

1018 data: ResponseData
1019
1020 def __init__(
1021 self,
1022 http_version: bytes,
1023 status_code: int,
1024 reason: bytes,
1025 headers: Headers | tuple[tuple[bytes, bytes], ...],
1026 content: bytes | None,
1027 trailers: None | Headers | tuple[tuple[bytes, bytes], ...],
1028 timestamp_start: float,
1029 timestamp_end: float | None,
1030 ):
1031 # auto-convert invalid types to retain compatibility with older code.
1032 if isinstance(http_version, str):
1033 http_version = http_version.encode("ascii", "strict")
1034 if isinstance(reason, str):
1035 reason = reason.encode("ascii", "strict")
1036
1037 if isinstance(content, str):
1038 raise ValueError(f"Content must be bytes, not {type(content).__name__}")
1039 if not isinstance(headers, Headers):
1040 headers = Headers(headers)
1041 if trailers is not None and not isinstance(trailers, Headers):
1042 trailers = Headers(trailers)
1043
1044 self.data = ResponseData(
1045 http_version=http_version,
1046 status_code=status_code,
1047 reason=reason,
1048 headers=headers,
1049 content=content,
1050 trailers=trailers,
1051 timestamp_start=timestamp_start,
1052 timestamp_end=timestamp_end,
1053 )
1054
1055 def __repr__(self) -> str:
1056 if self.raw_content:

Callers

nothing calls this directly

Calls 3

HeadersClass · 0.70
ResponseDataClass · 0.70
encodeMethod · 0.45

Tested by

no test coverage detected