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

Method _json_call

redis/http/http_client.py:326–350  ·  view source on GitHub ↗
(
        self,
        method: str,
        path: str,
        params: Optional[
            Mapping[str, Union[None, str, int, float, bool, list, tuple]]
        ] = None,
        headers: Optional[Mapping[str, str]] = None,
        timeout: Optional[float] = None,
        body: Optional[Union[bytes, str]] = None,
        expect_json: bool = True,
    )

Source from the content-addressed store, hash-verified

324
325 # Internal utilities
326 def _json_call(
327 self,
328 method: str,
329 path: str,
330 params: Optional[
331 Mapping[str, Union[None, str, int, float, bool, list, tuple]]
332 ] = None,
333 headers: Optional[Mapping[str, str]] = None,
334 timeout: Optional[float] = None,
335 body: Optional[Union[bytes, str]] = None,
336 expect_json: bool = True,
337 ) -> Union[HttpResponse, Any]:
338 resp = self.request(
339 method=method,
340 path=path,
341 params=params,
342 headers=headers,
343 body=body,
344 timeout=timeout,
345 )
346 if not (200 <= resp.status < 400):
347 raise HttpError(resp.status, resp.url, resp.text())
348 if expect_json:
349 return resp.json()
350 return resp
351
352 def _prepare_body(
353 self, json_body: Optional[Any] = None, data: Optional[Union[bytes, str]] = None

Callers 5

getMethod · 0.95
deleteMethod · 0.95
postMethod · 0.95
putMethod · 0.95
patchMethod · 0.95

Calls 4

requestMethod · 0.95
HttpErrorClass · 0.85
textMethod · 0.80
jsonMethod · 0.45

Tested by

no test coverage detected