MCPcopy
hub / github.com/redis/redis-py / _get_encoding

Method _get_encoding

redis/http/http_client.py:40–48  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38 return json.loads(self.text(encoding=self._get_encoding()))
39
40 def _get_encoding(self) -> str:
41 # Try to infer encoding from headers; default to utf-8
42 ctype = self.headers.get("content-type", "")
43 # Example: application/json; charset=utf-8
44 for part in ctype.split(";"):
45 p = part.strip()
46 if p.lower().startswith("charset="):
47 return p.split("=", 1)[1].strip() or "utf-8"
48 return "utf-8"
49
50
51class HttpError(Exception):

Callers 2

textMethod · 0.95
jsonMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected