MCPcopy
hub / github.com/mitmproxy/mitmproxy / encode

Method encode

mitmproxy/http.py:483–494  ·  view source on GitHub ↗

Encodes body with the given encoding, where e is "gzip", "deflate", "identity", "br", or "zstd". Any existing content-encodings are overwritten, the content is not decoded beforehand. *Raises:* - `ValueError`, when the specified content-encoding is invalid.

(self, encoding: str)

Source from the content-addressed store, hash-verified

481 self.content = decoded
482
483 def encode(self, encoding: str) -> None:
484 """
485 Encodes body with the given encoding, where e is "gzip", "deflate", "identity", "br", or "zstd".
486 Any existing content-encodings are overwritten, the content is not decoded beforehand.
487
488 *Raises:*
489 - `ValueError`, when the specified content-encoding is invalid.
490 """
491 self.headers["content-encoding"] = encoding
492 self.content = self.raw_content
493 if "content-encoding" not in self.headers:
494 raise ValueError(f"Invalid content encoding {encoding!r}")
495
496 def json(self, **kwargs: Any) -> Any:
497 """

Callers 15

installbuilder_installerFunction · 0.45
textMethod · 0.45
https_echMethod · 0.45
TXTMethod · 0.45
set_contentMethod · 0.45
set_textMethod · 0.45
__init__Method · 0.45
makeMethod · 0.45
authorityMethod · 0.45
_set_queryMethod · 0.45
_set_urlencoded_formMethod · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected