MCPcopy
hub / github.com/mitmproxy/mitmproxy / decode

Method decode

mitmproxy/http.py:465–481  ·  view source on GitHub ↗

Decodes body based on the current Content-Encoding header, then removes the header. If the message body is missing or empty, no action is taken. *Raises:* - `ValueError`, when the content-encoding is invalid and strict is True.

(self, strict: bool = True)

Source from the content-addressed store, hash-verified

463 self.data.timestamp_end = timestamp_end
464
465 def decode(self, strict: bool = True) -> None:
466 """
467 Decodes body based on the current Content-Encoding header, then
468 removes the header.
469
470 If the message body is missing or empty, no action is taken.
471
472 *Raises:*
473 - `ValueError`, when the content-encoding is invalid and strict is True.
474 """
475 if not self.raw_content:
476 # The body is missing (for example, because of body streaming or because it's a response
477 # to a HEAD request), so we can't correctly update content-length.
478 return
479 decoded = self.get_content(strict)
480 self.headers.pop("content-encoding", None)
481 self.content = decoded
482
483 def encode(self, encoding: str) -> None:
484 """

Callers 15

requestFunction · 0.45
textMethod · 0.45
https_echMethod · 0.45
__str__Method · 0.45
__str__Method · 0.45
_unescapeMethod · 0.45
_nativeFunction · 0.45
http_versionMethod · 0.45
get_contentMethod · 0.45
get_textMethod · 0.45
__init__Method · 0.45
methodMethod · 0.45

Calls 2

get_contentMethod · 0.95
popMethod · 0.45

Tested by 5

test_get_XSS_infoMethod · 0.36
test_query_injectionFunction · 0.36
test_contentencodeMethod · 0.36
test_responseMethod · 0.36