MCPcopy
hub / github.com/encode/httpx / _get_content_decoder

Method _get_content_decoder

httpx/_models.py:699–722  ·  view source on GitHub ↗

Returns a decoder instance which can be used to decode the raw byte content, depending on the Content-Encoding used in the response.

(self)

Source from the content-addressed store, hash-verified

697 return _parse_content_type_charset(content_type)
698
699 def _get_content_decoder(self) -> ContentDecoder:
700 """
701 Returns a decoder instance which can be used to decode the raw byte
702 content, depending on the Content-Encoding used in the response.
703 """
704 if not hasattr(self, "_decoder"):
705 decoders: list[ContentDecoder] = []
706 values = self.headers.get_list("content-encoding", split_commas=True)
707 for value in values:
708 value = value.strip().lower()
709 try:
710 decoder_cls = SUPPORTED_DECODERS[value]
711 decoders.append(decoder_cls())
712 except KeyError:
713 continue
714
715 if len(decoders) == 1:
716 self._decoder = decoders[0]
717 elif len(decoders) > 1:
718 self._decoder = MultiDecoder(children=decoders)
719 else:
720 self._decoder = IdentityDecoder()
721
722 return self._decoder
723
724 @property
725 def is_informational(self) -> bool:

Callers 2

iter_bytesMethod · 0.95
aiter_bytesMethod · 0.95

Calls 3

MultiDecoderClass · 0.85
IdentityDecoderClass · 0.85
get_listMethod · 0.45

Tested by

no test coverage detected